Skip to content

Commit 28eb60e

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 a7733e3 commit 28eb60e

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
@@ -1019,7 +1019,10 @@ def to_arrays(self, *attrs, include_key=False, order_by=None, limit=None, offset
10191019
arr = np.array(values)
10201020
except ValueError:
10211021
# Variable-size data (e.g., arrays of different shapes)
1022-
arr = np.array(values, dtype=object)
1022+
# Must assign individually to avoid numpy broadcasting issues
1023+
arr = np.empty(len(values), dtype=object)
1024+
for i, v in enumerate(values):
1025+
arr[i] = v
10231026
result_arrays.append(arr)
10241027

10251028
if include_key:

0 commit comments

Comments
 (0)