Skip to content

Commit 73d9894

Browse files
fix: Handle inhomogeneous array shapes in to_arrays()
When arrays have different shapes, np.array(values, dtype=object) can still fail due to numpy's broadcasting behavior. Instead, create an empty object array and assign elements individually. This matches v0.14.7 behavior where blobs were extracted from structured arrays with object dtype columns. Fixes #1380 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 39f4aa7 commit 73d9894

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/datajoint/expression.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,10 @@ def to_arrays(self, *attrs, include_key=False, order_by=None, limit=None, offset
860860
arr = np.array(values)
861861
except ValueError:
862862
# Variable-size data (e.g., arrays of different shapes)
863-
arr = np.array(values, dtype=object)
863+
# Must assign individually to avoid numpy broadcasting issues
864+
arr = np.empty(len(values), dtype=object)
865+
for i, v in enumerate(values):
866+
arr[i] = v
864867
result_arrays.append(arr)
865868

866869
if include_key:

0 commit comments

Comments
 (0)