Skip to content

Commit 3892510

Browse files
committed
MAINT: use .data explicitly instead of relying on __array__
required for Numpy 2.0 compatibility (issue #1100)
1 parent 2fd4267 commit 3892510

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

larray/core/array.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1404,9 +1404,8 @@ def describe(self, *args, percentiles=None) -> 'Array':
14041404
# ...
14051405
# }, 'statistic')
14061406
return stack({
1407-
# Note that np.isnan works as well as la.isnan thanks to __array_wrap__
1408-
# and using it avoids having a cyclic import
1409-
'count': (~np.isnan(self)).sum(*args),
1407+
# Not using la.isnan to avoid a cyclic import
1408+
'count': Array(~np.isnan(self.data), self.axes).sum(*args),
14101409
'mean': self.mean(*args),
14111410
'std': self.std(*args),
14121411
'min': self.min(*args),
@@ -2193,6 +2192,7 @@ def __setitem__(self, key, value, collapse_slices=True, translate_key=True, poin
21932192
text = 'axes are' if len(extra_axes) > 1 else 'axis is'
21942193
raise ValueError(f"Value {extra_axes!s} {text} not present in target subset {axes!s}. A value can only "
21952194
f"have the same axes or fewer axes than the subset being targeted")
2195+
value = value.data
21962196
self.data[raw_broadcasted_key] = value
21972197

21982198
# concerning keys this can make sense in several cases:

larray/core/axis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3663,7 +3663,7 @@ def _flat_lookup(self, flat_indices):
36633663
# TODO: this should be:
36643664
# return stack({axis.name: axis.i[inds] for axis, inds in zip(axes, axes_indices)}, axis='axis')
36653665
flat_axes = flat_indices.axes
3666-
axes_labels = self._iflat(flat_indices)
3666+
axes_labels = self._iflat(flat_indices.data)
36673667
return stack({axis.name: Array(axis_labels, flat_axes) for axis, axis_labels in zip(self, axes_labels)}, 'axis')
36683668

36693669
def _adv_keys_to_combined_axis_la_keys(self, key, wildcard=False, sep='_'):

0 commit comments

Comments
 (0)