Skip to content

Commit

Permalink
formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgsavage committed May 23, 2024
1 parent 6c610b1 commit 7155628
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 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.formatter.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

0 comments on commit 7155628

Please sign in to comment.