-
Notifications
You must be signed in to change notification settings - Fork 13
Give quantify errors context #43
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
Give quantify errors context #43
Conversation
thanks, @TomNicholas. A test checking that the name of the variable that is supposed to get the invalid unit appears in the error message would be great, but otherwise this looks good to me. I just noticed that since #41 the "Github Action per Pipeline" works. Did you do anything? |
Done.
Not that I'm aware of! Should there be an equivalent check for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we even iterating over there - coordinates?
coordinates and data:
pint-xarray/pint_xarray/conversion.py
Line 227 in 62c15c5
variables = itertools.chain([(obj.name, obj)], obj.coords.items()) |
I tried to get only a combined code path for both data and coords.
You will probably have to check against self.da.name
to find out if the error was raised for a coordinate or the data.
pint_xarray/tests/test_accessors.py
Outdated
@@ -222,6 +222,11 @@ def test_error_on_nonsense_units(self, example_unitless_ds): | |||
with pytest.raises(UndefinedUnitError): | |||
ds.pint.quantify(units={"users": "aecjhbav"}) | |||
|
|||
def test_error_indicates_problematic_variable(self, example_unitless_ds): | |||
ds = example_unitless_ds | |||
with raises_regex(UndefinedUnitError, "users"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the difference between raises_regex
and pytest.raises
' match
parameter?
I guess we can replace the Would you have the time to finish this PR, @TomNicholas? If not, I can try pushing to your branch. |
Hi @keewis , I'm afraid I don't have time to finish this right now, I can do in a month or two though probably. I remember this stalled because I was seeing some behaviour I didn't understand with my solution, so best not to merge without being confident about how it handles all cases... |
no worries. I tried to refactor the code in #56 (joining the |
@TomNicholas, would you have time to finish this? It is one of the major issues blocking the release of v0.2 |
Hi @keewis , that should work now, but I did have to change the raised error type to just a Raising just a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great, thanks, @TomNicholas. I have a few comments, but nothing major.
Co-authored-by: keewis <[email protected]>
Co-authored-by: keewis <[email protected]>
thanks again, @TomNicholas |
Fix for #42