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

Improve ufloat_fromstr documentation and parsing #287

Closed
Cs137 opened this issue Jan 18, 2025 · 2 comments · Fixed by #286
Closed

Improve ufloat_fromstr documentation and parsing #287

Cs137 opened this issue Jan 18, 2025 · 2 comments · Fixed by #286

Comments

@Cs137
Copy link
Contributor

Cs137 commented Jan 18, 2025

The ufloat_fromstr documentation does not mention how the function generates an uncertainty if the string representation does not contain one. Is it always 1 to the last significant digit? Also, I doubt that it makes sense to assign an uncertainty to a NaN value.

Examples:

  • ufloat_fromstr("123") -> 123.0+/-1.0
  • ufloat_fromstr("987") -> 987.0+/-1.0
  • ufloat_fromstr("0.9999") -> 0.9999+/-0.0001
  • ufloat_fromstr("nan") -> nan+/-1.0
@newville
Copy link
Member

@Cs137 Yes, it does default to an uncertainty of 1 in the least significant digit. That seems like an OK behavior compared to the otherwise obvious default of "raise ValueError".

I would say the same about what to do with the string "nan": that result seems acceptable, though "raise ValueError" might be a better choice.

Adding a note and/or example about this in the docs as part of #285 would be fine.

@Cs137
Copy link
Contributor Author

Cs137 commented Jan 20, 2025

Thanks for the answer @newville, I will pick up your proposal and add a note about it in #286.

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.

2 participants