Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sigfigs vs. uncertainty: integer interpretation is confusing #33

Open
Splines opened this issue Mar 28, 2024 · 1 comment · May be fixed by #41
Open

Sigfigs vs. uncertainty: integer interpretation is confusing #33

Splines opened this issue Mar 28, 2024 · 1 comment · May be fixed by #41
Assignees

Comments

@Splines
Copy link
Collaborator

Splines commented Mar 28, 2024

Currently

wiz.res("Test variable", 630, 15)

yields: TestVariable = 630.000000000000. This is due to the 15 being interpreted as number of significant figures. This is confusing as one might expect to get back TestVariable = 630 ± 15 as is the case for

wiz.res("Test variable", 630, 15.0)

We should somehow circumvent the first behavior, e.g. only allow passing in sigfigs via a named keyword, e.g. sigfigs=15. Maybe this can be achieved with plum somehow. It would also be great to completely disallow the mentioned usage but I'm not sure one can prevent users from not passing in an argument as keyword argument.

@Splines Splines changed the title Improve API to avoid confusion with sigfigs when passing in an integer Sigfigs vs. uncertainty: integer interpretation is problematic Mar 28, 2024
@Splines Splines changed the title Sigfigs vs. uncertainty: integer interpretation is problematic Sigfigs vs. uncertainty: integer interpretation is confusing Mar 28, 2024
@Splines Splines self-assigned this Apr 11, 2024
@Splines
Copy link
Collaborator Author

Splines commented Apr 11, 2024

New wiz.res() proposal:

wiz.res("a", 3.14, 0.2, unit="\m")
wiz.res("a", 3.14, str(0.2))

Use Unit as keyword argument, then we don't have the problem with the strings type anymore that lead to difficulties with multiple dispatch.

Note that

wiz.res("a", 3.14, "\m")

will fail as "\m" will be interpreted as uncertainty. (For this case, we should have a really good error message.)
Therefore, in the docs, we should only use unit=. Advanced users might omit this in the case where an uncertainty is specified: wiz.res("a", 3.14, 0.2, "\m"), but we won't promote that use case in the docs.

Splines added a commit that referenced this issue Apr 11, 2024
@Splines Splines linked a pull request Apr 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant