Skip to content

Commit

Permalink
Remove get_formatter replacement (was not introduced by numpy)
Browse files Browse the repository at this point in the history
  • Loading branch information
mhvk committed Jul 26, 2023
1 parent cf64e6c commit ffffe25
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
13 changes: 3 additions & 10 deletions astropy/units/quantity_helper/function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
dimensionless_unscaled,
)
from astropy.utils import isiterable
from astropy.utils.compat import NUMPY_LT_1_23, NUMPY_LT_2_0
from astropy.utils.compat import NUMPY_LT_1_23

# In 1.17, overrides are enabled by default, but it is still possible to
# turn them off using an environment variable. We use getattr since it
Expand Down Expand Up @@ -987,18 +987,11 @@ def array2string(a, *args, **kwargs):
a = a.value
else:
# See whether it covers our dtype.
if NUMPY_LT_2_0:
from numpy.core.arrayprint import _get_format_function

def get_formatter(data, options):
return _get_format_function(data, **options)

else:
from numpy.core.arrayprint import get_formatter
from numpy.core.arrayprint import _get_format_function

with np.printoptions(formatter=formatter) as options:
try:
ff = get_formatter(data=a.value, options=options)
ff = _get_format_function(a.value, **options)
except Exception:
# Shouldn't happen, but possibly we're just not being smart
# enough, so let's pass things on as is.
Expand Down
13 changes: 3 additions & 10 deletions astropy/utils/masked/function_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np

from astropy.units.quantity_helper.function_helpers import FunctionAssigner
from astropy.utils.compat import NUMPY_LT_1_23, NUMPY_LT_1_24, NUMPY_LT_2_0
from astropy.utils.compat import NUMPY_LT_1_23, NUMPY_LT_1_24

# This module should not really be imported, but we define __all__
# such that sphinx can typeset the functions with docstrings.
Expand Down Expand Up @@ -927,16 +927,9 @@ def __call__(self, x):

@classmethod
def from_data(cls, data, **options):
if NUMPY_LT_2_0:
from numpy.core.arrayprint import _get_format_function
from numpy.core.arrayprint import _get_format_function

def get_formatter(data, options):
return _get_format_function(data, **options)

else:
from numpy.core.arrayprint import get_formatter

return cls(get_formatter(data=data, options=options))
return cls(_get_format_function(data, **options))


def _array2string(a, options, separator=" ", prefix=""):
Expand Down

0 comments on commit ffffe25

Please sign in to comment.