Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1615 from MichaelTiemannOSC/parse-uncertainties
This commit allows to parse uncertain numbers e.g. (1.0+/-0.2)e+03 Enable Pint to consume uncertain quantities. Signed-off-by: 72577720+MichaelTiemannOSC@users.noreply.github.com * Fix problems identified by python -m pre_commit run --all-files Signed-off-by: MichaelTiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Enhance support for `uncertainties`. See #1611, #1614. Signed-off-by: MichaelTiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fix up failures and errors found by test suite. Signed-off-by: MichaelTiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Copy in changes from PR1596 Signed-off-by: 72577720+MichaelTiemannOSC@users.noreply.github.com * Create modular uncertainty parser layer Based on feedback, tokenize uncertainties on top of default tokenizer, not instead of default tokenizer. Signed-off-by: MichaelTiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fix conflict merge error Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update util.py Fixes problems parsing currency symbols that also show up when dealing with uncertainties. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update pint_eval.py Handle negative numbers using uncertainty parenthesis notation. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update pint_eval.py Ahem...use walrus operator for side-effect, not truth value. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fixed to work with both + and - e notation in the actually processing of the exponent, not just in the parsing of the exponent. i.e., (5.01+/-0.07)e+04 Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fix test suite failures Manually fix test_issue_1400. Let other failures (which are not related to uncertainties) fail. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fix tokenizer merge error in pint/util.py When using pint_eval.tokenizer don't try to import tokenizer from pint.compat. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Merge cleanup: pint_eval.py needs tokenize Clean up merge import error. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Make black happier Run `black` with default arguments to try to match whatever `black` wants to see in the CI/CD world. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Make ruff happy Remove unused redefinition of tokenizer in toktest.py. Also remove unnecessary import of pint_eval from top-level (it's imported inside the function definition that needs it). Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Make ruff happier Fix ruff errors missed in previous commit. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update toktest.py Fix whitespace error created by `ruff --fix` that `black` didn't like. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update test_util.py Follow deprecation of use_decimal from pint/util.py Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fix additional regressions in test suite If we have the uncertainties library loaded, go ahead and use the uncertainty_tokenizer by default. This fixes problems with standard Pandas tests that expect the tokenizer to do the right thing without any special setup. Also, prevent exception when a loop in consensus_name_attr (pandas-dev/pandas/core/common.py(86))) tests equality with a None argument. Otherwise the zero_or_nan test raises an exception. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update quantity.py Teach Pint's PlainQuantity about the Pandas pd.NA value so that ndim works. Otherwise, it naively delegates to NumpyQuantity, which is the road to perdition for PintArrays. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Make `babel` a dependency for testbase Here's hoping this fixes the CI/CD problem with test_1400. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Update .readthedocs.yaml Removing `system_packages: false` as suggested by @keewis Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> * Fix failing tests Fix isnan to use unp.isnan as appropriate for both duck_array_type and objects of UFloat types. Fix a minor typo in pint/facets/__init__.py comment. In test_issue_1400, use decorators to ensure babel library is loaded when needed. pyproject.toml: revert change to testbase; we fixed with decorators instead. Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> --------- Signed-off-by: 72577720+MichaelTiemannOSC@users.noreply.github.com Signed-off-by: MichaelTiemann <72577720+MichaelTiemannOSC@users.noreply.github.com> Signed-off-by: Michael Tiemann <72577720+MichaelTiemannOSC@users.noreply.github.com>
- Loading branch information