home / github / issues

Menu
  • Search all tables
  • GraphQL API

issues: 576502871

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
576502871 MDU6SXNzdWU1NzY1MDI4NzE= 3834 encode_cf_datetime() casts dask arrays to NumPy arrays 13301940 open 0     2 2020-03-05T20:11:37Z 2022-04-09T03:10:49Z   MEMBER      

Currently, when xarray.coding.times.encode_cf_datetime() is called, it always casts the input to a NumPy array. This is not what I would expect when the input is a dask array. I am wondering if we could make this operation lazy when the input is a dask array?

https://github.com/pydata/xarray/blob/01462d65c7213e5e1cddf36492c6a34a7e53ce55/xarray/coding/times.py#L352-L354

```python In [46]: import numpy as np

In [47]: import xarray as xr

In [48]: import pandas as pd

In [49]: times = pd.date_range("2000-01-01", "2001-01-01", periods=11)

In [50]: time_bounds = np.vstack((times[:-1], times[1:])).T

In [51]: arr = xr.DataArray(time_bounds).chunk()

In [52]: arr
Out[52]: <xarray.DataArray (dim_0: 10, dim_1: 2)> dask.array<xarray-\<this-array>, shape=(10, 2), dtype=datetime64[ns], chunksize=(10, 2), chunktype=numpy.ndarray> Dimensions without coordinates: dim_0, dim_1

In [53]: xr.coding.times.encode_cf_datetime(arr)
Out[53]: (array([[ 0, 52704], [ 52704, 105408], [105408, 158112], [158112, 210816], [210816, 263520], [263520, 316224], [316224, 368928], [368928, 421632], [421632, 474336], [474336, 527040]]), 'minutes since 2000-01-01 00:00:00', 'proleptic_gregorian')

```

Cc @jhamman

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

Links from other tables

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