issue_comments: 774001075
This data as json
html_url | issue_url | id | node_id | user | created_at | updated_at | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/pydata/xarray/pull/4760#issuecomment-774001075 | https://api.github.com/repos/pydata/xarray/issues/4760 | 774001075 | MDEyOklzc3VlQ29tbWVudDc3NDAwMTA3NQ== | 10194086 | 2021-02-05T12:22:41Z | 2021-02-05T12:22:41Z | MEMBER | @keewis The following test is giving me trouble: I now try to reproduce what it does but I cannot even manage that... I think the following is what the test does but it fails with ```python import numpy as np import pint import xarray as xr unit_registry = pint.UnitRegistry() dtype = np.int64 data_unit1 = unit_registry.m data_unit2 = unit_registry.mm array1 = np.linspace(0, 10, 2 * 5).reshape(2, 5).astype(dtype) array2 = np.linspace(0, 8, 2 * 5).reshape(2, 5).astype(dtype) x = np.arange(2) # * dim_unit1 y1 = np.arange(5) # * dim_unit1 y2 = np.arange(2, 7) # * dim_unit2 u1 = np.array([3, 5, 7, 8, 9]) # * coord_unit1 u2 = np.array([7, 8, 9, 11, 13]) # * coord_unit2 coords1 = {"x": x, "y": y1} coords2 = {"x": x, "y": y2} data_array1 = xr.DataArray(data=array1 * data_unit1, coords=coords1, dims=("x", "y")) data_array2 = xr.DataArray(data=array2 * data_unit2, coords=coords2, dims=("x", "y")) fill_value = 10 actual_a, actual_b = xr.align(data_array1, data_array2, join="outer", fill_value=fill_value * data_unit1) ``` The underlying problem is that when I run this test with
```python-traceback
> assert_allclose(expected_b, actual_b)
/home/mathause/code/xarray/xarray/tests/test_units.py:542:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/home/mathause/code/xarray/xarray/tests/__init__.py:208: in assert_allclose
xarray.testing.assert_allclose(a, b, check_dtype=check_dtype, **kwargs)
/home/mathause/code/xarray/xarray/testing.py:178: in assert_allclose
assert allclose, formatting.diff_array_repr(
/home/mathause/code/xarray/xarray/core/formatting.py:667: in diff_array_repr
if not equiv(a, b, check_dtype=check_dtype):
/home/mathause/code/xarray/xarray/testing.py:40: in _data_allclose_or_equiv
return duck_array_ops.allclose_or_equiv(
/home/mathause/code/xarray/xarray/core/duck_array_ops.py:249: in allclose_or_equiv
arr1 = asarray(arr1)
/home/mathause/code/xarray/xarray/core/duck_array_ops.py:184: in asarray
return data if is_duck_array(data) else xp.asarray(data)
/home/mathause/conda/envs/xarray_dev/lib/python3.8/site-packages/numpy/core/_asarray.py:102: in asarray
return array(a, dtype, copy=False, order=order)
/home/mathause/code/xarray/xarray/core/common.py:139: in __array__
return np.asarray(self.values, dtype=dtype)
/home/mathause/code/xarray/xarray/core/dataarray.py:634: in values
return self.variable.values
/home/mathause/code/xarray/xarray/core/variable.py:544: in values
return _as_array_or_item(self._data)
/home/mathause/code/xarray/xarray/core/variable.py:276: in _as_array_or_item
data = np.asarray(data)
/home/mathause/conda/envs/xarray_dev/lib/python3.8/site-packages/numpy/core/_asarray.py:102: in asarray
return array(a, dtype, copy=False, order=order)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Quantity([[10. 10. 0. 0. 1. 2. 3.]
[10. 10. 4. 5. 6. 7. 8.]], 'millimeter')>, t = None
def __array__(self, t=None):
> warnings.warn(
"The unit of the quantity is stripped when downcasting to ndarray.",
UnitStrippedWarning,
stacklevel=2,
)
E pint.errors.UnitStrippedWarning: The unit of the quantity is stripped when downcasting to ndarray.
/home/mathause/conda/envs/xarray_dev/lib/python3.8/site-packages/pint/quantity.py:1683: UnitStrippedWarning
```
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
778069594 |