Can .pint.magnitude return a DataArray instead?

Open
#151 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
data

Research direction

Start by tracing the implementation and tests for DataArray.pint.magnitude, then compare its current NumPy result with DataArray.data.magnitude and DataArray.as_numpy(). Review the unresolved discussion to determine whether returning a DataArray is the intended API; done requires an agreed behavior and tests covering the resulting type and NumPy extraction path.

Written by the indexing model from the issue text.

Description

Currently DataArray.pint.magnitude returns a numpy array. Can it return a DataArray instead? We can always extract the numpy array using DataArray.data.magnitude.

Just realized I can also use DataArray.as_numpy() but perhaps this is still worth considering?

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

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.

More from xarray-contrib/pint-xarray

All issues in xarray-contrib/pint-xarray

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.