Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QuantityIndex #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pintxarray/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .accessors import PintDataArrayAccessor, PintDatasetAccessor
from .indexing import QuantityIndex
1 change: 1 addition & 0 deletions pintxarray/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
if not IS_NEP18_ACTIVE:
raise ImportError("NUMPY_EXPERIMENTAL_ARRAY_FUNCTION is not enabled")

# TODO do we need this? xarray chooses it's own labels anyway
try:
mpl = import_module("matplotlib")
has_mpl = True
Expand Down
29 changes: 29 additions & 0 deletions pintxarray/indexing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import pandas as pd
from pandas.core.base import IndexOpsMixin

from pint import Quantity, Unit


# TODO does pandas supply some kind of abstract base class for indexer objects?
class QuantityIndex(IndexOpsMixin):
def __init__(self, index=pd.Index, units=None, unit_registry=None,
decode_cf=False):
self._index = index
self._units = units

@property
def units(self):
...

@property
def magnitude(self):
...

def dequantify(self):
...

def to(self, units):
...

def to_base_units(self):
...