Skip to content

Commit d432dbc

Browse files
committed
Revert "revise valid_index"
This reverts commit b5b92ec.
1 parent b5b92ec commit d432dbc

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

WrightTools/data/_join.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,15 @@ def combine(data, out, item_name, new_idx, transpose, slice_):
209209
vals[:] = 0
210210
# Use advanced indexing to populate vals, a temporary array with same shape as out
211211
valid_index = tuple(wt_kit.valid_index(new_idx, new.shape))
212-
vals[valid_index] = old[:].transpose(transpose)[slice_]
212+
# temp patch--numpy now doesn't let you write array element with sequence of length 1
213+
try:
214+
vals[valid_index] = old[:].transpose(transpose)[slice_]
215+
except ValueError as e:
216+
if all(
217+
[isinstance(i, int) for i in valid_index]
218+
): # temp patch: setting element to array of size 1 used to work
219+
valid_index = [[i] for i in valid_index]
220+
vals[valid_index] = old[:].transpose(transpose)[slice_]
213221

214222
# Overlap methods are accomplished by adding the existing array with the one added
215223
# for this particular data. Thus locations which should be set, but conflict by

WrightTools/kit/_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def valid_index(index, shape) -> tuple:
385385
if isinstance(i, slice):
386386
out.append(slice(None))
387387
else:
388-
out.append([0])
388+
out.append(0)
389389
else:
390390
out.append(i)
391391
return tuple(out[::-1])

tests/data/join.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,7 @@ def test_transpose():
713713
test_1D_plus_2D_plus_3D()
714714
test_overlap_first()
715715
test_overlap_last()
716+
test_overlap_sum()
716717
test_overlap_max()
717718
test_overlap_min()
718719
test_overlap_mean()

tests/kit/valid_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def test__1_5__7():
1818
def test__4_2_12__1_25_1():
1919
index = (4, 2, 12)
2020
shape = (1, 25, 1)
21-
assert wt.kit.valid_index(index, shape) == ([0], 2, [0])
21+
assert wt.kit.valid_index(index, shape) == (0, 2, 0)
2222

2323

2424
def test__s__23():

0 commit comments

Comments
 (0)