nan length coordinates
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Is your feature request related to a problem? Please describe.
When using arrays with a nan shape, I'd like to provide a coordinate specification from a delayed object, which is my responsibility to make sure has the right chunks and length.
Describe the solution you'd like
Below are three examples that I think should work, where I give a coordinate via a dask array, a dask series, and a dask index. Currently, all three examples error out by computing the coordinate length (triggering an unwanted dask computation!), and then indicating that its different than the array's corresponding length, which is nan.
import dask
import dask.array as da
import dask.dataframe as dd
import numpy as np
import pandas as pd
import xarray as xr
def foo():
return np.arange(4)
arr = da.from_delayed(dask.delayed(foo)(), shape=(np.nan,), dtype=int)
idx = da.from_delayed(dask.delayed(foo)(), shape=(np.nan,), dtype=int)
ddf = dd.from_pandas(pd.DataFrame({'y': np.arange(4)}), npartitions=1)
arr0 = xr.DataArray(arr, coords=[('z', idx)])
arr1 = xr.DataArray(arr, coords=[('z', ddf['y'])])
arr2 = xr.DataArray(arr, coords=[('z', ddf.index)])
Error:
ValueError: conflicting sizes for dimension 'z': length nan on the data but length 4 on coordinate 'z'
Describe alternatives you've considered
After computations to complete add the missing coordinate. This requires carrying around the delayed index with the delayed array.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the three DataArray construction examples in the issue and tracing how coordinates are validated when the data shape contains nan. The work is done when dask array, series, and index coordinates can be attached without computing their lengths or raising a false size conflict.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, pandas, python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100