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 — Drop unify's ignored scalar flags inside the library, and share the UDT leaf walkers by eriknw · Pull Request #665 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Nov 4, 2026

Copy link
Copy Markdown
Member

Stacked on #663. Follow-ups to #591 from review. This is a refactor with no change in behavior. Every existing
test passes unchanged, and one test is added.

unify's scalar flags. dtypes.unify has ignored is_left_scalar and is_right_scalar
since #591, which types a literal before it reaches unify. The library no longer passes
them:

  • the fill-value and ewise_union calls in Vector, Matrix and Scalar;
  • get_typed_op (in graphblas.core), which took them only to pass them on and no longer
    takes them.

unify keeps both keywords, and its docstring now says it accepts and ignores them.

Walkers.

  • _has_half_leaf, _has_narrow_float_leaf, _has_duration_leaf,
    _numba_untyped_array_element and _raw_bytes_element now test the leaves of one walker,
    dtypes._iter_leaves. It walks records, nested records, arrays of records and arrays of
    arrays, as each of them did.
  • _check_leaves_compare uses _leaf_dtypes, which its inner function repeated.
  • _int_beyond_leaf is gone. _beyond_as_infinity read a literal by the same rules. It now
    returns None when no int is beyond its leaf's range, so a comparison walks the literal
    once.
  • _check_udt_pair and _corresponding_leaves ask _record_leaf_mismatch whether two records
    pair: the same nesting, the same names in the same order, and the same shape for each field.
    Each words its reason as before. Array UDTs keep their own rules, which differ on purpose:
    operands broadcast, but a stored element does not.

Some walkers stay separate. Each reads a literal by its own rules, and merging them would
change a result:

  • _refuse_misfit_fields: a non-sequence has no parts.
  • _weak_literal_udt's record reader: only a number fills a record, and a wrong length
    refuses the whole literal.
  • _nats_in_leaf_units: a list is a sequence of elements.
  • _as_record_parts: it turns a dict into a tuple, and keeps a scalar as it is.
  • _leaf_dtypes: it treats an array of records as one leaf.

Tests. A new row in test_jit_udt_np_type_numba_cannot_type checks a field that is an
array of arrays of bool, which numpy keeps unflattened. It still gets the message for an array
Numba cannot type.

A differential check compared the old and new walkers on 362 dtypes:

  • every scalar kind, including text, bytes, raw void, dates, durations, float16 and complex;
  • arrays of them, and arrays of arrays;
  • random records with array fields;
  • nested records and arrays of records;
  • titled fields and out-of-order offsets.

It also covered 8,014 literal values and 131,044 dtype pairs. All 665,406 results matched on
numpy 1.24.4, 2.1.3, 2.4.6 and 2.5.4. The full suite passes with --runslow on both backends,
without Numba, and with the CI's C-scalar substitution.

Questions for Erik

# Question Recommendation
1 Deprecate unify's is_left_scalar and is_right_scalar (a DeprecationWarning when given), or keep accepting them silently? Keep them silent here. A deprecation can go with the next release that removes other things.
2 get_typed_op no longer takes the two keywords. It is in graphblas.core, and nothing in the stack, graphblas-algorithms or nx-graphblas passes them. Accept them again for other callers? No, graphblas.core is private.
3 _record_leaf_mismatch is the one walker change that adds lines (+21), to put the record pairing rule in one place. Keep it? Keep it. The rule is in one place, and its docstring shows where the rules for an op and for a cast part. It is the last commit, so it can be dropped alone.

🤖 Generated with Claude Code

Sorry, something went wrong.

Uh oh!

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

All reactions
@eriknw
eriknw added this pull request to stack #666 November 4, 2026 20:51
@codecov

codecov Bot commented Nov 4, 2026 •
edited
Loading

Uh oh!

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

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.82353% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 99.20%. Comparing base (084d928) to head (d65e1d2).

Additional details and impacted files
@@                    Coverage Diff                    @@
##           56-udt-jit-edge-cases     #665      +/-   ##
=========================================================
+ Coverage                  99.08%   99.20%   +0.11%     
=========================================================
  Files                        109      109              
  Lines                      35859    35842      -17     
  Branches                    4100     4087      -13     
=========================================================
+ Hits                       35532    35557      +25     
+ Misses                       183      164      -19     
+ Partials                     144      121      -23     
🚀 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 force-pushed the 57-udt-cleanups branch from b85d9a4 to 20ce9b8 Compare November 8, 2026 04:51
@eriknw
eriknw force-pushed the 57-udt-cleanups branch 3 times, most recently from f666203 to 080a941 Compare November 9, 2026 15:51
@eriknw
eriknw force-pushed the 57-udt-cleanups branch 2 times, most recently from 5ec2d02 to 427a2fa Compare November 10, 2026 17:12
@eriknw
eriknw force-pushed the 57-udt-cleanups branch 14 times, most recently from b9fbfa3 to 8387a9e Compare November 11, 2026 05:42
@eriknw
eriknw removed this pull request from stack #666 November 12, 2026 06:13
@eriknw
eriknw changed the base branch from 56-udt-jit-edge-cases to main November 12, 2026 06:15
@eriknw
eriknw force-pushed the 57-udt-cleanups branch from 8387a9e to bc9c687 Compare November 12, 2026 06:15
@eriknw
eriknw changed the base branch from main to 56-udt-jit-edge-cases November 12, 2026 06:16
@eriknw
eriknw added this pull request to stack #670 November 12, 2026 06:17
@eriknw
eriknw force-pushed the 57-udt-cleanups branch 2 times, most recently from bc40c1d to d65e1d2 Compare November 12, 2026 17:36
eriknw added 7 commits November 12, 2026 14:32
@eriknw
Call unify without the scalar flags it ignores
c3b08bb
unify has ignored is_left_scalar and is_right_scalar since a literal is typed
before it gets there, so the fill-value and ewise_union calls in Vector,
Matrix and Scalar stop passing them.
@eriknw
Stop passing the ignored scalar flags through get_typed_op
7b5b0ed
get_typed_op took is_left_scalar and is_right_scalar only to hand them to
unify, which ignores them. Drop them from get_typed_op and from every
caller in Vector, Matrix, Scalar and _get_typed_op_from_exprs.
@eriknw
Say that unify accepts and ignores its scalar flags
f629c4d
@eriknw
Find a leaf of a kind in a UDT with one walker
e774190
_has_half_leaf, _has_narrow_float_leaf, _has_duration_leaf,
_numba_untyped_array_element and _raw_bytes_element each walked records,
nested records, arrays of records and arrays of arrays to test each leaf.
They now test the leaves dtypes._iter_leaves yields, which walks them the
same way. A test checks that a field holding an array of arrays of bool,
which numpy keeps unflattened, still gets the message for an array Numba
cannot type.
@eriknw
List the leaves eq compares with _leaf_dtypes
aba900e
The inner leaves() of _check_leaves_compare was _leaf_dtypes again.
@eriknw
Find and replace an int beyond its leaf's range in one walk
92974d6
_int_beyond_leaf and _beyond_as_infinity read a literal's parts by the
same rules, and the comparison path called the first only to decide
whether to call the second. _beyond_as_infinity now returns None when
there is no such int, and _int_beyond_leaf goes.
@eriknw
Pair two records' leaves by one rule for an op and for a cast
dbebe98
_check_udt_pair and _corresponding_leaves each compared the leaf paths and
then the field shapes of two records, one to raise KeyError and one to
return a reason. _record_leaf_mismatch now says where they differ, and
each caller words it as before. The rules for array UDTs stay apart:
operands broadcast, a stored element does not.
@eriknw
eriknw force-pushed the 57-udt-cleanups branch from d65e1d2 to dbebe98 Compare November 12, 2026 20:35
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.