align ignores `copy`
Open
Nobody has claimed this yet.
bug
topic-indexing
topic-performance
- 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?
cc @benbovy
xref #7730
import numpy as np
import xarray as xr
arr = np.random.randn(10, 10, 365*30)
time = xr.date_range("2000", periods=30*365, calendar="noleap")
da = xr.DataArray(arr, dims=("y", "x", "time"), coords={"time": time})
year = da["time.year"]
xr.align(da, year, join="outer", copy=False)
This should result in no copies, but does
Describe the solution you'd like
I think we need to check aligner.copy and/or aligner.reindex (maybe?) before copying here
Describe alternatives you've considered
No response
Additional context
No response
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 provided xarray.align example, then inspect the referenced section of xarray/core/dataset.py around lines 2805–2818 and trace how copy=False is handled. Done means alignment with copy=False avoids the unnecessary copies shown in the report, with the behavior covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- numpy, python
- Domain
- data, performance
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100