Skip to content

Commit

Permalink
provide more context to errors (#92)
Browse files Browse the repository at this point in the history
* reverse the order of checks in the DimensionalityError constructor

* simplify the str method

* add a custom exception for invalid units

* use the new exception to present all invalid units at once

* replace the custom class by a formatter

* use the new formatter to collect and present unit errors

* fix a leftover reference to the custom error class

* synchronize DataArray quantify with Dataset quantify

* more removing of the custom error classes

* fix a bug in reindex and rely on convert_units to raise an error

* fix most other methods

* update whats-new.rst

* fix a link [skip-ci]

* explicitly parse the units

* limit the errors caught in quantify to ValueError and UndefinedUnitError

* remove the custom error class

* actually call loc when expecting errors

* also check whether the error for a invalid attribute is properly formatted

* rewrite the tests for to
  • Loading branch information
keewis authored Apr 24, 2021
1 parent 91ef50d commit 7bf1cc7
Show file tree
Hide file tree
Showing 6 changed files with 447 additions and 545 deletions.
8 changes: 4 additions & 4 deletions docs/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ What's new
- rewrite :py:meth:`Dataset.pint.quantify` and :py:meth:`DataArray.pint.quantify`,
to use pint's `parse_units` instead of `parse_expression` (:pull:`40`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- ensure the variable which causes the error is explicit if an error occurs in
:py:meth:`Dataset.pint.quantify` (:pull:`43`)
By `Tom Nicholas <https://github.com/TomNicholas>`_.
- ensure the variables which causes the error is explicit if an error occurs in
:py:meth:`Dataset.pint.quantify` and other methods (:pull:`43`, :pull:`91`)
By `Tom Nicholas <https://github.com/TomNicholas>`_ and `Justus Magin <https://github.com/keewis>`_.
- refactor the internal conversion functions (:pull:`56`)
By `Justus Magin <https://github.com/keewis>`_.
- allow converting indexes (except :py:class:`pandas.MultiIndex`) (:pull:`56`)
Expand Down Expand Up @@ -45,7 +45,7 @@ What's new
By `Justus Magin <https://github.com/keewis>`_.
- implement :py:meth:`Dataset.pint.interpolate_na` and :py:meth:`DataArray.pint.interpolate_na` (:pull:`82`).
By `Justus Magin <https://github.com/keewis>`_.
- expose :py:func:`pint_xarray.accessors.setup_registry` as public API (:pull:`89`)
- expose :py:func:`pint_xarray.setup_registry` as public API (:pull:`89`)
By `Justus Magin <https://github.com/keewis>`_.

v0.1 (October 26 2020)
Expand Down
Loading

0 comments on commit 7bf1cc7

Please sign in to comment.