Skip to content

Commit

Permalink
update ci master version (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage authored May 23, 2024
1 parent 3f9568b commit b87d0f1
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-pint-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
python-version: [3.9, "3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]
numpy: ["numpy>=1.20.3,<2.0.0"]
pandas: ["pandas==2.0.2", ]
pint: ["pint>=0.21.1"]
Expand Down
2 changes: 1 addition & 1 deletion docs/user/reading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ The units are harder to read than they need be, so lets change pint's `default f

.. ipython:: python
pint_pandas.PintType.ureg.default_format = "P~"
pint_pandas.PintType.ureg.formatter.default_format = "P~"
df_.pint.dequantify()
or the entire table's units
Expand Down
2 changes: 1 addition & 1 deletion notebooks/pint-pandas.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@
"metadata": {},
"outputs": [],
"source": [
"pint_pandas.PintType.ureg.default_format = \"P~\"\n",
"pint_pandas.PintType.ureg.formatter.default_format = \"P~\"\n",
"df_.pint.dequantify()"
]
},
Expand Down
20 changes: 15 additions & 5 deletions pint_pandas/pint_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import warnings
from importlib.metadata import version
from typing import Any, Callable, Dict, Optional, Union, cast
from packaging.version import parse as version_parse

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -363,9 +364,15 @@ def _formatter(self, boxed=False):
when ``boxed=False`` and :func:`str` is used when
``boxed=True``.
"""
float_format = pint.formatting.remove_custom_flags(
self.dtype.ureg.default_format
)
# TODO: remove this once 0.24 is min pint version
if version_parse(pint.__version__).base_version < "0.24":
float_format = pint.formatting.remove_custom_flags(
self.dtype.ureg.default_format
)
else:
float_format = pint.formatting.remove_custom_flags(
self.dtype.ureg.formatter.default_format
)

def formatting_function(quantity):
if isinstance(quantity.magnitude, float):
Expand Down Expand Up @@ -979,7 +986,11 @@ def quantify(self, level=-1):

def dequantify(self):
def formatter_func(dtype):
formatter = "{:" + dtype.ureg.default_format + "}"
# TODO: remove once pint 0.24 is min version supported
if version_parse(pint.__version__).base_version < "0.24":
formatter = "{:" + dtype.ureg.default_format + "}"
else:
formatter = "{:" + dtype.ureg.formatter.default_format + "}"
return formatter.format(dtype.units)

df = self._obj
Expand Down Expand Up @@ -1133,7 +1144,6 @@ class DelegatedScalarMethod(DelegatedMethod):

for attr in [
"debug_used",
"default_format",
"dimensionality",
"dimensionless",
"force_ndarray",
Expand Down
1 change: 0 additions & 1 deletion pint_pandas/testsuite/test_pandas_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ class TestSeriesAccessors(object):
@pytest.mark.parametrize(
"attr",
[
"default_format",
"dimensionality",
"dimensionless",
"force_ndarray",
Expand Down

0 comments on commit b87d0f1

Please sign in to comment.