pydata / pydata/xarray

Astropy quantities are converted to bare arrays when creating an Index

Open
#10,920 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

topic-arrays topic-indexing
Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

What is your issue?

When provided as a data variable, an astropy Quantity is kept as a Quantity. But when provided as an index through the coords argument when constructing a Dataset, the Quantity is converted to an array, erasing the units. Is it possible to fix this?

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 reported behavior when constructing an xarray Dataset with an astropy Quantity passed through coords, then compare it with the data-variable case described in the issue. Trace the Dataset index-construction path and verify that the completed change preserves the Quantity and its units in both cases.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.