Skip to content

Commit a3b2242

Browse files
committed
cleanup
1 parent 6e7e960 commit a3b2242

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

larray/core/array.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,11 +2127,9 @@ def _translate_axis_key(self, axis_key):
21272127
return self._translate_axis_key_chunk(axis_key)
21282128

21292129
def __getitem__(self, key, collapse_slices=False, translate_key=True):
2130-
data = self.data
2131-
# FIXME: I have a huge problem with boolean axis labels + non points
21322130
raw_broadcasted_key, res_axes, transpose_indices = self.axes._key_to_raw_and_axes(key, collapse_slices,
21332131
translate_key)
2134-
res_data = data[raw_broadcasted_key]
2132+
res_data = self.data[raw_broadcasted_key]
21352133
if res_axes:
21362134
res = Array(res_data, res_axes)
21372135
# if some axes have been moved in front because of advanced indexing, we transpose them back to their
@@ -2145,7 +2143,6 @@ def __setitem__(self, key, value, collapse_slices=True, translate_key=True):
21452143
# total_axes = self.axes + key.axes + value.axes
21462144
# expanded = self.expand(total_axes)
21472145
# data = np.asarray(expanded.data)
2148-
data = self.data
21492146
raw_broadcasted_key, target_axes, _ = self.axes._key_to_raw_and_axes(key, collapse_slices, translate_key)
21502147
if isinstance(value, Array):
21512148
# TODO: the check_compatible should be included in broadcast_with
@@ -2161,7 +2158,7 @@ def __setitem__(self, key, value, collapse_slices=True, translate_key=True):
21612158
text = 'axes are' if len(extra_axes) > 1 else 'axis is'
21622159
raise ValueError("Value {!s} {} not present in target subset {!s}. A value can only have the same axes "
21632160
"or fewer axes than the subset being targeted".format(extra_axes, text, axes))
2164-
data[raw_broadcasted_key] = value
2161+
self.data[raw_broadcasted_key] = value
21652162

21662163
# concerning keys this can make sense in several cases:
21672164
# single bool Array key with extra axes.

larray/core/axis.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,18 +2563,17 @@ def _translate_axis_key_chunk(self, axis_key):
25632563
"""
25642564
axis_key = remove_nested_groups(axis_key)
25652565

2566-
if isinstance(axis_key, Group) and axis_key.axis is not None:
2566+
if isinstance(axis_key, IGroup) and axis_key.axis is not None:
25672567
# retarget to real axis, if needed
25682568
# only retarget IGroup and not LGroup to give the opportunity for axis.translate to try the "ticks"
25692569
# version of the group ONLY if key.axis is not real_axis (for performance reasons)
2570-
if isinstance(axis_key, IGroup):
2571-
if axis_key.axis in self:
2572-
axis_key = axis_key.retarget_to(self[axis_key.axis])
2573-
else:
2574-
# axis associated with axis_key may not belong to self.
2575-
# In that case, we translate IGroup to labels and search for a compatible axis
2576-
# (see end of this method)
2577-
axis_key = axis_key.to_label()
2570+
if axis_key.axis in self:
2571+
axis_key = axis_key.retarget_to(self[axis_key.axis])
2572+
else:
2573+
# axis associated with axis_key may not belong to self.
2574+
# In that case, we translate IGroup to labels and search for a compatible axis
2575+
# (see end of this method)
2576+
axis_key = axis_key.to_label()
25782577

25792578
# already positional
25802579
if isinstance(axis_key, IGroup):

0 commit comments

Comments
 (0)