Skip to content

Commit

Permalink
Remove workarounds for numpy <= 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
mhvk committed Jan 31, 2023
1 parent 31dcf6c commit 78eebf3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 12 deletions.
6 changes: 1 addition & 5 deletions astropy/units/tests/test_quantity_array_methods.py
@@ -1,13 +1,12 @@
# The purpose of these tests are to ensure that calling quantities using
# array methods returns quantities with the right units, or raises exceptions.
import sys

import numpy as np
import pytest
from numpy.testing import assert_array_equal

from astropy import units as u
from astropy.utils.compat import NUMPY_LT_1_21_1, NUMPY_LT_1_22
from astropy.utils.compat import NUMPY_LT_1_22


class TestQuantityArrayCopy:
Expand Down Expand Up @@ -125,9 +124,6 @@ def test_swapaxes(self):
assert q_swapaxes.unit == q.unit
assert np.all(q_swapaxes.value == q.value.swapaxes(0, 2))

@pytest.mark.xfail(
sys.byteorder == "big" and NUMPY_LT_1_21_1, reason="Numpy GitHub Issue 19153"
)
def test_flat_attributes(self):
"""While ``flat`` doesn't make a copy, it changes the shape."""
q = np.arange(6.0).reshape(3, 1, 2) * u.m
Expand Down
2 changes: 0 additions & 2 deletions astropy/units/tests/test_structured.py
Expand Up @@ -13,7 +13,6 @@
from astropy.tests.helper import check_pickling_recovery, pickle_protocol # noqa: F401
from astropy.units import Quantity, StructuredUnit, Unit, UnitBase
from astropy.units.quantity import _structured_unit_like_dtype
from astropy.utils.compat import NUMPY_LT_1_21_1
from astropy.utils.masked import Masked


Expand Down Expand Up @@ -230,7 +229,6 @@ def test_deepcopy(self):
assert su_copy == self.pv_t_unit
assert su_copy._units is not self.pv_t_unit._units

@pytest.mark.skipif(NUMPY_LT_1_21_1, reason="https://stackoverflow.com/q/69571643")
def test_pickle(self, pickle_protocol): # noqa: F811
check_pickling_recovery(self.pv_t_unit, pickle_protocol)

Expand Down
2 changes: 0 additions & 2 deletions astropy/utils/compat/numpycompat.py
Expand Up @@ -9,7 +9,6 @@
from astropy.utils import minversion

__all__ = [
"NUMPY_LT_1_21_1",
"NUMPY_LT_1_22",
"NUMPY_LT_1_22_1",
"NUMPY_LT_1_23",
Expand All @@ -20,7 +19,6 @@
# TODO: It might also be nice to have aliases to these named for specific
# features/bugs we're checking for (ex:
# astropy.table.table._BROKEN_UNICODE_TABLE_SORT)
NUMPY_LT_1_21_1 = not minversion(np, "1.21.1")
NUMPY_LT_1_22 = not minversion(np, "1.22")
NUMPY_LT_1_22_1 = not minversion(np, "1.22.1")
NUMPY_LT_1_23 = not minversion(np, "1.23")
Expand Down
7 changes: 4 additions & 3 deletions astropy/utils/masked/core.py
Expand Up @@ -811,9 +811,10 @@ def __array_ufunc__(self, ufunc, method, *inputs, **kwargs):
mask = False

else: # pragma: no cover
# Can only get here if neither input nor output was masked, but
# perhaps axis or where was masked (in NUMPY_LT_1_21 this is
# possible). We don't support this.
# Can only get here if neither input nor output was masked.
# This used to be possible in numpy < 1.21 with, say, a masked
# axis or where. It should not happen any more, but
# signal we do not support it just in case.
return NotImplemented

elif method in {"reduceat", "at"}: # pragma: no cover
Expand Down

0 comments on commit 78eebf3

Please sign in to comment.