Skip to content

Commit 77f9cd3

Browse files
committed
change the raised error to TypeError
1 parent 449181d commit 77f9cd3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pint_xarray/_expects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def wrapper(*args, **kwargs):
7878
isinstance(value, (xr.DataArray, xr.Dataset))
7979
and value.pint.units
8080
):
81-
raise ValueError(
81+
raise TypeError(
8282
"Passed in a quantity where none was expected"
8383
)
8484
continue
@@ -87,7 +87,7 @@ def wrapper(*args, **kwargs):
8787
elif isinstance(value, (xr.DataArray, xr.Dataset)):
8888
params.arguments[name] = value.pint.to(units).pint.dequantify()
8989
else:
90-
raise ValueError(
90+
raise TypeError(
9191
f"Attempting to convert non-quantity {value} to {units}."
9292
)
9393
except Exception as e:

pint_xarray/tests/test_expects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ def func(a, b, c=1):
5555
(
5656
ureg.Quantity(1, "m"),
5757
(None, None),
58-
ValueError,
58+
TypeError,
5959
"Passed in a quantity where none was expected",
6060
True,
6161
),
62-
(1, ("m", None), ValueError, "Attempting to convert non-quantity", True),
62+
(1, ("m", None), TypeError, "Attempting to convert non-quantity", True),
6363
(
6464
1,
6565
(None,),

0 commit comments

Comments
 (0)