Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion graphblas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,9 @@ def _update(self, expr, mask=None, accum=None, replace=False, input_mask=None):
if type(expr) is Scalar:
scalar = expr
else:
dtype = self.dtype if self.dtype._is_udt else None
try:
scalar = Scalar.from_value(expr, is_cscalar=None, name="")
scalar = Scalar.from_value(expr, dtype, is_cscalar=None, name="")
except TypeError:
raise TypeError(
"Assignment value must be a valid expression type, not "
Expand Down
2 changes: 1 addition & 1 deletion graphblas/tests/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -3430,7 +3430,7 @@ def test_udt():
[0, 0], [0, 1], np.array([(0, 0), (1, 2)], dtype=record_dtype), nrows=2, ncols=2, dtype=udt
)
assert A.isequal(expected)
A[:, :] = 0
A << 0
zeros = Matrix.from_values([0, 0, 1, 1], [0, 1, 0, 1], 0, dtype=udt)
assert A.isequal(zeros)
A(A.S)[:, :] = 1
Expand Down
6 changes: 6 additions & 0 deletions graphblas/tests/test_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -1990,6 +1990,12 @@ def test_udt():
v[:] = 1
w[:] = np.array([1, 1, 1], dtype=np.uint8)
assert v.isequal(w)
v[:] = 0
v << 1
assert v.isequal(w)
v[:] = 0
v << (1, 1, 1)
assert v.isequal(w)

indices, values = v.to_values()
assert_array_equal(values, np.ones((2, 3), dtype=np.uint16))
Expand Down