Skip to content

Commit

Permalink
1darray subdtype
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage committed Aug 26, 2024
1 parent 324f73b commit c275f34
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 4 deletions.
9 changes: 9 additions & 0 deletions 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Channels:
- conda-forge
- defaults
Platform: win-64
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

53 changes: 53 additions & 0 deletions 4.2.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Channels:
- conda-forge
- defaults
Platform: win-64
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

environment location: C:\Users\A\mambaforge\envs\pp_aug241

added / updated specs:
- nbformat


The following packages will be downloaded:

package | build
---------------------------|-----------------
importlib_resources-6.4.2 | pyhd8ed1ab_0 31 KB conda-forge
jsonschema-4.23.0 | pyhd8ed1ab_0 73 KB conda-forge
jsonschema-specifications-2023.12.1| pyhd8ed1ab_0 16 KB conda-forge
nbformat-5.10.4 | pyhd8ed1ab_0 99 KB conda-forge
python-fastjsonschema-2.20.0| pyhd8ed1ab_0 221 KB conda-forge
referencing-0.35.1 | pyhd8ed1ab_0 41 KB conda-forge
rpds-py-0.20.0 | py311h533ab2d_0 204 KB conda-forge
zipp-3.20.0 | pyhd8ed1ab_0 20 KB conda-forge
------------------------------------------------------------
Total: 705 KB

The following NEW packages will be INSTALLED:

importlib_resourc~ conda-forge/noarch::importlib_resources-6.4.2-pyhd8ed1ab_0
jsonschema conda-forge/noarch::jsonschema-4.23.0-pyhd8ed1ab_0
jsonschema-specif~ conda-forge/noarch::jsonschema-specifications-2023.12.1-pyhd8ed1ab_0
nbformat conda-forge/noarch::nbformat-5.10.4-pyhd8ed1ab_0
pkgutil-resolve-n~ conda-forge/noarch::pkgutil-resolve-name-1.3.10-pyhd8ed1ab_1
python-fastjsonsc~ conda-forge/noarch::python-fastjsonschema-2.20.0-pyhd8ed1ab_0
referencing conda-forge/noarch::referencing-0.35.1-pyhd8ed1ab_0
rpds-py conda-forge/win-64::rpds-py-0.20.0-py311h533ab2d_0
zipp conda-forge/noarch::zipp-3.20.0-pyhd8ed1ab_0

The following packages will be SUPERSEDED by a higher-priority channel:

certifi pkgs/main/win-64::certifi-2024.7.4-py~ --> conda-forge/noarch::certifi-2024.7.4-pyhd8ed1ab_0


Proceed ([y]/n)?

Downloading and Extracting Packages: ...working... done
Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
9 changes: 9 additions & 0 deletions 9
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Channels:
- conda-forge
- defaults
Platform: win-64
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

# All requested packages already installed.

11 changes: 7 additions & 4 deletions pint_pandas/pint_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):

def _convert_np_result(self, result):
if isinstance(result, _Quantity) and is_list_like(result.m):
return PintArray.from_1darray_quantity(result)
return PintArray.from_1darray_quantity(result, self.dtype.subdtype)
elif isinstance(result, _Quantity):
return result
elif type(result) is tuple:
Expand Down Expand Up @@ -866,8 +866,8 @@ def convert_values(param):

if op.__name__ == "divmod":
return (
cls.from_1darray_quantity(res[0]),
cls.from_1darray_quantity(res[1]),
cls.from_1darray_quantity(res[0], self.dtype.subdtype),
cls.from_1darray_quantity(res[1], self.dtype.subdtype),
)

if coerce_to_dtype:
Expand Down Expand Up @@ -1201,6 +1201,7 @@ def __init__(self, pandas_obj):
else:
self._validate(pandas_obj)
self.pandas_obj = pandas_obj
self.pintarray = pandas_obj.values
self.quantity = pandas_obj.values.quantity
self._index = pandas_obj.index
self._name = pandas_obj.name
Expand Down Expand Up @@ -1263,7 +1264,9 @@ def delegated_method(*args, **kwargs):
result = method(*args, **kwargs)
if self.to_series:
if isinstance(result, _Quantity):
result = PintArray.from_1darray_quantity(result)
result = PintArray.from_1darray_quantity(
result, object.__getattribute__(obj, "pintarray").dtype.subdtype
)
result = Series(result, index, name=name)
return result

Expand Down

0 comments on commit c275f34

Please sign in to comment.