pydata / pydata/xarray

map removes non-dimensional coordinate variables

Open
#6,445 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.