map removes non-dimensional coordinate variables
Open
Nobody has claimed this yet.
bug
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
What happened?
ds = xr.Dataset(
{"a": ("x", [1, 2, 3])},
coords={"c": ("x", [1, 2, 3]), "d": ("y", [1, 2, 3, 4])}
)
print(ds.coords)
mapped = ds.map(lambda x: x)
print(mapped.coords)
Variables d gets dropped in the map call. It does not share any dimensions with any of the data variables.
Coordinates:
c (x) int64 1 2 3
d (y) int64 1 2 3 4
Coordinates:
c (x) int64 1 2 3
What did you expect to happen?
No response
Minimal Complete Verifiable Example
No response
Relevant log output
No response
Anything else we need to know?
No response
Environment
xarray 2022.03.0
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 Dataset.map example and inspect the ds.map entry point to determine why coordinate variable d is dropped when it uses an unrelated dimension. Done means the mapped dataset retains both c and d coordinates, with the regression covered by a test for this example.
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
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100