Skip to content

adapt the pint + dask test to the newest version of pint #7855

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

Merged
merged 5 commits into from
May 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions xarray/tests/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -5627,16 +5627,20 @@ def test_merge(self, variant, unit, error, dtype):

@requires_dask
class TestPintWrappingDask:
@pytest.mark.skipif(
version.parse(pint.__version__) <= version.parse("0.21"),
reason="pint didn't support dask properly before 0.21",
)
def test_duck_array_ops(self):
import dask.array

d = dask.array.array([1, 2, 3])
q = pint.Quantity(d, units="m")
q = unit_registry.Quantity(d, units="m")
da = xr.DataArray(q, dims="x")

actual = da.mean().compute()
actual.name = None
expected = xr.DataArray(pint.Quantity(np.array(2.0), units="m"))
expected = xr.DataArray(unit_registry.Quantity(np.array(2.0), units="m"))

assert_units_equal(expected, actual)
# Don't use isinstance b/c we don't want to allow subclasses through
Expand Down