Exact alignment should allow missing dimension coordinates
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Code Sample, a copy-pastable example if possible
import xarray as xr
xr.align(xr.DataArray([1, 2, 3], dims='x'),
xr.DataArray([1, 2, 3], dims='x', coords=[[0, 1, 2]]),
join='exact')
Problem description
This currently results in an error, but a missing index of size 3 does not actually conflict:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-15-1d63d3512fb6> in <module>()
1 xr.align(xr.DataArray([1, 2, 3], dims='x'),
2 xr.DataArray([1, 2, 3], dims='x', coords=[[0, 1, 2]]),
----> 3 join='exact')
/usr/local/lib/python3.6/dist-packages/xarray/core/alignment.py in align(*objects, **kwargs)
129 raise ValueError(
130 'indexes along dimension {!r} are not equal'
--> 131 .format(dim))
132 index = joiner(matching_indexes)
133 joined_indexes[dim] = index
ValueError: indexes along dimension 'x' are not equal
This surfaced as an issue on StackOverflow: https://stackoverflow.com/questions/51308962/computing-matrix-vector-multiplication-for-each-time-point-in-two-dataarrays
Expected Output
Both output arrays should end up with the x coordinate from the input that has it, like the output of the above expression if join='inner':
(<xarray.DataArray (x: 3)>
array([1, 2, 3])
Coordinates:
* x (x) int64 0 1 2, <xarray.DataArray (x: 3)>
array([1, 2, 3])
Coordinates:
* x (x) int64 0 1 2)
Output of xr.show_versions()
xarray: 0.10.7
pandas: 0.22.0
numpy: 1.14.5
scipy: 0.19.1
netCDF4: None
h5netcdf: None
h5py: 2.8.0
Nio: None
zarr: None
bottleneck: None
cyordereddict: None
dask: None
distributed: None
matplotlib: 2.1.2
cartopy: None
seaborn: 0.7.1
setuptools: 39.1.0
pip: 10.0.1
conda: None
pytest: None
IPython: 5.5.0
sphinx: None
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 with the alignment implementation behind xr.align and reproduce the provided join='exact' example. Check how missing dimension indexes are compared, then verify that both arrays receive the existing x coordinate without raising an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100