Skip to content

Extend the wrong-kind mask guard to dup and whole-object update - #614

Open
eriknw wants to merge 1 commit into
33-udf-ret-dtypefrom
34-mask-guard-dup-update
Open

Extend the wrong-kind mask guard to dup and whole-object update#614
eriknw wants to merge 1 commit into
33-udf-ret-dtypefrom
34-mask-guard-dup-update

Conversation

@eriknw

@eriknw eriknw commented Aug 4, 2026

Copy link
Copy Markdown
Member

A.dup(mask=v.S) and C(mask=v.S) << A assign with C(mask)[...] = A,
which builds a setitem expression, so the strict mask-kind check
in BaseType._update did not apply and a Vector mask on a Matrix
output reached GrB_Matrix_assign, leaking a raw cffi error:

TypeError: Error calling GrB_Matrix_assign: ... initializer for
ctype 'struct GB_Matrix_opaque *' must be a pointer to same type,
not cdata 'struct GB_Vector_opaque *'

Validate the mask kind in the Matrix-valued branch of
Matrix._prep_for_assign, mirroring the guard the Vector-valued
branch already has. This also covers C(v.S)[:, :] << A and the
submask form C:, : << A. Row and column assignment with a
Vector mask (C(v.S)[0, :] << w and friends) is handled in earlier
branches and remains valid.

The guard keys on mask.parent.ndim rather than exact type, the same
idiom _check_mask uses, so a Vector subclass's mask is caught too. Two
pre-existing guards in the Vector-valued branch and one more in the
scalar path still use exact-type checks and carry the same subclass
hole; they predate this commit and are left for their own change.


Stack created with GitHub Stacks CLIGive Feedback 💬

@eriknw
eriknw marked this pull request as ready for review August 4, 2026 16:07
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch 2 times, most recently from 5e95d6b to 53549cd Compare August 5, 2026 00:06
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from 53549cd to 4f02903 Compare August 5, 2026 03:18
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from 4f02903 to 16184fb Compare August 5, 2026 17:44
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from 16184fb to 7231bc7 Compare August 5, 2026 18:03
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from 7231bc7 to be3ba76 Compare August 5, 2026 18:05
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from be3ba76 to 9a88a91 Compare August 6, 2026 07:59
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from 9a88a91 to e92ec62 Compare August 6, 2026 15:39
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from e92ec62 to ca732f2 Compare August 6, 2026 15:41
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch 2 times, most recently from 7817be7 to d90065c Compare August 6, 2026 20:41
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from d90065c to 6303f42 Compare August 7, 2026 02:49
A.dup(mask=v.S) and C(mask=v.S) << A assign with C(mask)[...] = A,
which builds a __setitem__ expression, so the strict mask-kind check
in BaseType._update did not apply and a Vector mask on a Matrix
output reached GrB_Matrix_assign, leaking a raw cffi error:

    TypeError: Error calling GrB_Matrix_assign: ... initializer for
    ctype 'struct GB_Matrix_opaque *' must be a pointer to same type,
    not cdata 'struct GB_Vector_opaque *'

Validate the mask kind in the Matrix-valued branch of
Matrix._prep_for_assign, mirroring the guard the Vector-valued
branch already has. This also covers C(v.S)[:, :] << A and the
submask form C[:, :](v.S) << A. Row and column assignment with a
Vector mask (C(v.S)[0, :] << w and friends) is handled in earlier
branches and remains valid.

The guard keys on mask.parent.ndim rather than exact type, the same
idiom _check_mask uses, so a Vector subclass's mask is caught too. Two
pre-existing guards in the Vector-valued branch and one more in the
scalar path still use exact-type checks and carry the same subclass
hole; they predate this commit and are left for their own change.
@eriknw
eriknw force-pushed the 34-mask-guard-dup-update branch from 6303f42 to 587692a Compare August 7, 2026 05:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant