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 — Rewrite `A.select(A < 7)` to a select expression by eriknw · Pull Request #252 · python-graphblas/python-graphblas

Conversation

@eriknw

@eriknw eriknw commented Jun 1, 2022

Copy link
Copy Markdown
Member

Straightforward pattern-match and rewrite. This is an optimization of (4) from #234 and #251.

Sorry, something went wrong.

Uh oh!

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

All reactions
@eriknw
Rewrite A.select(A < 7) to a select expression
db3bc31
@eriknw
eriknw requested a review from jim22k June 1, 2022 02:12
@coveralls

coveralls commented Jun 1, 2022

Copy link
Copy Markdown

Coverage Status

Coverage increased (+0.4%) to 99.366% when pulling db3bc31 on eriknw:rewrite_select_expr into ecfcd0c on python-graphblas:main.

All reactions

Sorry, something went wrong.

Uh oh!

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

jim22k
jim22k approved these changes Jun 1, 2022
View reviewed changes
@eriknw

eriknw commented Jun 1, 2022

Copy link
Copy Markdown
Member Author

Pattern matching ftw!

All reactions

Sorry, something went wrong.

Uh oh!

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

@eriknw
eriknw merged commit 5d0b361 into python-graphblas:main Jun 1, 2022
eriknw added a commit that referenced this pull request Nov 3, 2026
@eriknw
Select by a transposed comparison as by its mask, not by the untransp…
0a3c573
…osed one

select._match_expr rewrote A.select(A.T == x) as select.valueeq(A, x):
its clause "args[0] is parent or args[0].T is parent" matched the
transpose of the parent, and the rewrite then compared A itself, dropping
the transpose and, for a matrix that is not square, the dimension check:

    S = Matrix.from_coo([0, 1], [1, 0], [1, 5], nrows=2, ncols=2)
    S.select(S.T == 1)
    before: (0, 1) = 1
    after:  (1, 0) = 5, as S.select((S.T == 1).new()) gives
    B (2 x 3): B.select(B.T == 1)
    before: a 2 x 3 result
    after:  DimensionMismatch

The clause is now "args[0] is parent"; anything else takes the mask path.
On main since #252, for built-in dtypes. "Select a UDT's elements equal or
unequal to a value, as == compares them" sent UDT eq and ne through the
same clause, which had made A.select(A.T == x) on a UDT a wrong answer
where it raised before. test_udt_select_by_equality now uses a 2 x 3
matrix with entries off the diagonal, and a mask with replace.
@eriknw eriknw mentioned this pull request Nov 3, 2026
Fix UDT, dtype and JIT edge cases found in #591's review #663
Open
@eriknw eriknw mentioned this pull request Nov 12, 2026
Fix wrong answers from select by A.T, coo import and isclose #668
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@jim22k jim22k jim22k approved these changes

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.

3 participants

@eriknw @coveralls @jim22k
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.