GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Reject building a user monoid from a built-in BinaryOp by eriknw · Pull Request #617 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Aug 5, 2026

Copy link
Copy Markdown
Member

Registering a monoid from a built-in binaryop used to crash partway
through construction:

Monoid.register_new("mymax", binary.max, 0)
    AttributeError: 'TypedBuiltinBinaryOp' object has no attribute
    '_monoid' and no __dict__ for setting new attributes

and by the time it raised, it had already repointed binary.max's monoid
association at the half-built monoid, so binary.max.monoid stayed
corrupted for the rest of the session. (This is the latent bug that the
fmax/fmin identity test surfaced on mapnumpy=True CI runs.)

Even patched over, the result would lie. SuiteSparse ignores the
identity passed to GrB_Monoid_new whenever the built-in op already has a
built-in monoid, measured with GxB_Monoid_identity:

Monoid.register_new("mymax", binary.max, 0)[INT64] -> -9223372036854775808
the same monoid built on a UDF max                 -> 0

The override applies to exactly the ops that have built-in monoids (max,
min, plus, times, any) and not the rest (minus, first, second, pow,
bor, lxor), so a permissive fix would produce a monoid whose Python-side
identity silently disagrees with what GraphBLAS computes with. If a
monoid over a built-in op's function made sense, the built-in monoid
would already exist.

Monoid._build now rejects built-in binaryops up front with a TypeError
that points at BinaryOp.register_new / register_anonymous as the way to
build a monoid over the same function with a chosen identity. Built-ins
are detected as ops with neither a Python function nor a numba function,
which also covers assembled ops like binary.numpy.float_power. The
rejection happens before any object is created, so nothing is mutated on
the failing path.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from dbce7b2 to 488622d Compare August 5, 2026 03:18
This was referenced Aug 5, 2026
Test the from_networkx int32 widening and correct its coverage claim #618
Closed
Extend the monoid guard to built-ins that carry a UDT fallback func #619
Merged
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 488622d to 8f138a4 Compare August 5, 2026 17:44
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 8f138a4 to 2c9fdaa Compare August 5, 2026 18:03
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 2c9fdaa to 88922bd Compare August 5, 2026 18:05
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 88922bd to 99668c2 Compare August 6, 2026 07:59
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 99668c2 to 1b70585 Compare August 6, 2026 15:39
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 1b70585 to 076218f Compare August 6, 2026 15:41
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch 2 times, most recently from 1ddb541 to dd0e7ef Compare August 6, 2026 20:41
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from dd0e7ef to 35065c5 Compare August 7, 2026 02:49
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 35065c5 to 727fe12 Compare August 7, 2026 05:09
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 727fe12 to 896cbc8 Compare August 26, 2026 17:30
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 896cbc8 to c14bd42 Compare September 18, 2026 03:09
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from c14bd42 to a303e64 Compare September 18, 2026 03:46
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from a303e64 to 654b144 Compare September 18, 2026 17:34
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 654b144 to c7ab91b Compare September 18, 2026 17:39
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from be1975f to b55b217 Compare September 26, 2026 05:23
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from b55b217 to 0b9e279 Compare September 26, 2026 05:25
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch 3 times, most recently from 0291da9 to 5012466 Compare October 1, 2026 17:11
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 5012466 to 68a11e3 Compare October 1, 2026 22:04
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 68a11e3 to d100dfa Compare October 3, 2026 04:57
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch 2 times, most recently from 6c76440 to fe3d69d Compare October 4, 2026 06:21
@eriknw
eriknw removed this pull request from stack #634 October 8, 2026 21:02
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from fe3d69d to 286cb5a Compare October 8, 2026 21:40
@eriknw
eriknw added this pull request to stack #635 October 8, 2026 21:46
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch from 286cb5a to 1198675 Compare October 9, 2026 03:06
@eriknw
eriknw force-pushed the 36-monoid-builtin-binaryop-guard branch 2 times, most recently from 7cfc1e1 to d3533cb Compare October 14, 2026 18:45
@eriknw
eriknw removed this pull request from stack #635 October 19, 2026 07:45
@eriknw
eriknw changed the base branch from 35-ssconfig-attr-guard to main October 19, 2026 07:46
@codecov

codecov Bot commented Oct 19, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (306176a) to head (512b8ab).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #617      +/-   ##
==========================================
+ Coverage   98.72%   98.82%   +0.10%     
==========================================
  Files         105      105              
  Lines       31088    31099      +11     
  Branches     3646     3647       +1     
==========================================
+ Hits        30691    30733      +42     
+ Misses        247      227      -20     
+ Partials      150      139      -11     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eriknw
eriknw commented Nov 11, 2026
View reviewed changes
Comment thread graphblas/core/operator/monoid.py
def _build(cls, name, binaryop, identity, *, is_idempotent=False, anonymous=False):
if type(binaryop) is not BinaryOp:
raise TypeError(f"binaryop must be a BinaryOp, not {type(binaryop)}")
if _is_builtin_binaryop(binaryop):

@eriknw eriknw Nov 11, 2026

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder whether it's actually worth making _is_builtin_binaryop a single-line helper functions that is used in one location.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eriknw
Reject building a user monoid from a built-in BinaryOp
512b8ab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@eriknw
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.