diff options
author | Ryan May <rmay@ucar.edu> | 2023-03-08 16:41:17 -0700 |
---|---|---|
committer | Ryan May <rmay@ucar.edu> | 2023-03-08 16:44:30 -0700 |
commit | 90008e8402bde93b9c3fbb7d884d39f98ee6415c (patch) | |
tree | 799f03056fa5e5c2c27b1d1f79ad09873731af4c /pint/testsuite/test_dask.py | |
parent | 5314065540de1ef99df9bd637e5064fcca2aa8d9 (diff) | |
download | pint-90008e8402bde93b9c3fbb7d884d39f98ee6415c.tar.gz |
Fix __dask_postcompute__() to better preserve type
In Unidata/MetPy#2945, a call to dask's .compute() was causing the
resulting type to be a different Quantity() variant (from pint.util
rather than the parent registry), which resulted in isinstance()
failing. This changes things to use the appropriate type from `self`
rather than hard-coded class names.
Diffstat (limited to 'pint/testsuite/test_dask.py')
-rw-r--r-- | pint/testsuite/test_dask.py | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/pint/testsuite/test_dask.py b/pint/testsuite/test_dask.py index 69c80fe..f4dee6a 100644 --- a/pint/testsuite/test_dask.py +++ b/pint/testsuite/test_dask.py @@ -149,6 +149,8 @@ def test_compute_persist_equivalent(local_registry, dask_array, numpy_array): assert np.all(res_compute == res_persist) assert res_compute.units == res_persist.units == units_ + assert type(res_compute) == local_registry.Quantity + assert type(res_persist) == local_registry.Quantity @pytest.mark.parametrize("method", ["compute", "persist", "visualize"]) |