Skip to content

Commit

Permalink
attempt to fix compat with numpy 1.23-1.24
Browse files Browse the repository at this point in the history
  • Loading branch information
neutrinoceros committed Jan 11, 2024
1 parent b370b9e commit d354fbb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions astropy/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from astropy.io.registry import UnifiedReadWriteMethod
from astropy.units import Quantity, QuantityInfo
from astropy.utils import ShapedLikeNDArray, isiterable
from astropy.utils.compat import NUMPY_LT_1_25
from astropy.utils.console import color_print
from astropy.utils.data_info import BaseColumnInfo, DataInfo, MixinInfo
from astropy.utils.decorators import format_doc
Expand Down Expand Up @@ -3722,6 +3723,7 @@ def _rows_equal(self, other):
self_is_masked = self.has_masked_columns
other_is_masked = isinstance(other, np.ma.MaskedArray)

whitelist = (TypeError, ValueError if not NUMPY_LT_1_25 else DeprecationWarning)
# One table is masked and the other is not
if self_is_masked != other_is_masked:
# remap variables to a and b where a is masked and b isn't
Expand All @@ -3734,15 +3736,15 @@ def _rows_equal(self, other):
false_mask = np.zeros(1, dtype=[(n, bool) for n in a.dtype.names])
try:
result = (a.data == b) & (a.mask == false_mask)
except (TypeError, ValueError):
except whitelist:
# numpy may complain that structured array are not comparable (TypeError)
# or that operands are not brodcastable (ValueError)
# see https://github.com/astropy/astropy/issues/13421
result = np.array([False])
else:
try:
result = self.as_array() == other
except (TypeError, ValueError):
except whitelist:
result = np.array([False])

return result
Expand Down

0 comments on commit d354fbb

Please sign in to comment.