issues: 1328531407
This data as json
id | node_id | number | title | user | state | locked | assignee | milestone | comments | created_at | updated_at | closed_at | author_association | active_lock_reason | draft | pull_request | body | reactions | performed_via_github_app | state_reason | repo | type |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1328531407 | I_kwDOAMm_X85PL8fP | 6876 | min and max methods changing dtype to float64 | 70525572 | open | 0 | 1 | 2022-08-04T12:15:28Z | 2022-10-13T17:23:25Z | NONE | I'm working with datasets that have coordinates with lots of decimal places. As I don't need this I reassign cords and transform the dtype to float32. For calculating the extent of the dataset a standard procedure is to use the min() and max() methods but using them over the float32 coordinates yields the float64 values which leads to misaligned coordinates. Minimum reproducible example: ```python import xarray as xr import numpy as np da = xr.DataArray( data=np.array([1.2, 2.2, 3.3], dtype=np.float32), coords={"x": [1.345, 2.345, 3.345]}, dims=("x",), ) print(da[0].dtype) # dtype('float32') print(da.min().dtype) # dtype('float64') print(type(np.min(da.values))) # dtype('float32') ``` Is there a reason for this? |
{ "url": "https://api.github.com/repos/pydata/xarray/issues/6876/reactions", "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
13221727 | issue |