xarray-contrib / xarray-contrib/pint-xarray

recreating indexes after conversion

Open
#269 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
119
Forks
15
PR merge metrics
No merged PRs in 30d

Description

@benbovy, do you have any idea about how to best do this? from_variables is a class method, so it won't preserve any options that were already on the index, even if we don't pass an empty dict. This shouldn't block this PR, though.

Originally posted by @keewis in https://github.com/xarray-contrib/pint-xarray/pull/163#discussion_r1669996550

I'm afraid there is no easy way of converting units (i.e, new coordinate values + re-create the underlying index + wrap it as a new PintIndex) that would be completely agnostic of the underlying index type.

Actually I would rather drop the index and let the user re-create it manually. This is also better behavior for custom indexes that may be expensive to build (e.g., a KDTree).

For convenience we might also choose to auto-convert indexes for Xarray built-in index types only (and pass the options in a hard-coded way, if any... currently PandasIndex and PandasMultiIndex do not expose any option).

Originally posted by @benbovy in https://github.com/xarray-contrib/pint-xarray/pull/163#discussion_r1670068233

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 with the discussion from PR 163 linked in the issue and determine the intended behavior for indexes during unit conversion. The work is done when the project has a decided, implemented approach that accounts for underlying index types and preserves or drops indexes as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.