home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 166642852

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
166642852 MDU6SXNzdWUxNjY2NDI4NTI= 913 dtype changes after .load() 296686 closed 0     4 2016-07-20T17:56:35Z 2016-07-21T00:49:02Z 2016-07-21T00:49:02Z CONTRIBUTOR      

I've found that in some situations a DataArray using dask as the storage backend will report its dtype as float32, but then once the data has been loaded (eg. with load()) the dtype changes to float64.

This surprised me, and actually caught me out in a few situations where I was writing code to export a DataArray to a custom file format (where the metadata specification for the custom format needed to know the dtype but then complained when the actual dtype was difference). Is this desired behaviour, or a bug? (Or somewhere in between...?).

This only seems to occur with dask-backed DataArrays, and not 'normal' DataArrays.

Example:

Create the example netCDF file like this:

python xa = xr.DataArray(data=np.random.rand(10, 10).astype(np.float32)) xa.to_dataset(name='data').to_netcdf('test.nc')

Then doing some simple operations with normal DataArrays:

python normal_data = xr.open_dataset('test.nc')['data'] normal_data.dtype # => float32 normal_data.mean(dim='dim_0').dtype # => float32

But doing the same thing in dask:

python dask_data = xr.open_dataset('test.nc', chunks={'dim_0': 2})['data'] dask_data.mean(dim='dim_0').dtype # => float32 dask_data.mean(dim='dim_0').load().dtype # => float64

{
    "url": "https://api.github.com/repos/pydata/xarray/issues/913/reactions",
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  completed 13221727 issue

Links from other tables

  • 1 row from issues_id in issues_labels
  • 4 rows from issue in issue_comments
Powered by Datasette · Queries took 0.554ms · About: xarray-datasette