Skip to content

Make apply accept IndexUnaryOps - #229

Merged
jim22k merged 3 commits into
python-graphblas:mainfrom
jim22k:apply_indexunary
May 6, 2022
Merged

jim22k merged 3 commits into
python-graphblas:mainfrom
jim22k:apply_indexunary

Conversation

@jim22k

@jim22k jim22k commented May 5, 2022

Copy link
Copy Markdown
Member
  • Add IndexUnaryOp and typed versions
  • New gb.indexunary namespace
  • Apply works with both IndexUnaryOp and SelectOp
    • The only real difference is what happens when you call those ops. Passing them to apply is treated identically when calling into SuiteSparse.
  • Add tests

Add IndexUnaryOp and typed versions
New gb.indexunary namespace
@jim22k
jim22k requested a review from eriknw May 5, 2022 21:50
@jim22k

jim22k commented May 5, 2022

Copy link
Copy Markdown
Member Author

This is the minimum effort to make this work. A future PR will address user-defined versions for both IndexUnaryOp and SelectOp.

However, @eriknw if you feel strongly that we need to fix the way things work for Vectors (i.e. must use rowindex, rowle, etc) as part of this PR, I am okay adding that. Or we can push it to a future PR as well.

@eriknw eriknw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

w00t! Thanks Jim! I had mostly (entirely?) minor nits. You know, it's already been super-nice having select operators. I forget where IndexUnary operators will be used. Less often, though, right? It was a good call to separate them.

I'm fine taking an incremental approach to PRs. One should implement what one is comfortable with, and hopefully anything still to be done is noted somewhere or intended to be implemented soon-ish.

Btw, a speaker at PyCon gave an impassioned speech about about reaching and staying at 100% coverage as a virtue and making your project better. So, this is a friendly reminder to please look at all missed coverage at https://coveralls.io/github/python-graphblas/python-graphblas. We're not sticklers about coverage (well, I kinda am for myself), but good coverage is appreciated. I think I may re-enable the coveralls chat bot. I suppose it wasn't that noisy, I just wasn't used to it is all.

Comment thread graphblas/matrix.py Resolved
Comment thread graphblas/matrix.py Resolved
Comment thread graphblas/matrix.py Resolved
Comment thread graphblas/operator.py Resolved
Comment thread graphblas/vector.py Resolved
Comment thread graphblas/vector.py Resolved
Comment thread graphblas/matrix.py Resolved
Comment thread graphblas/vector.py Resolved
Comment thread graphblas/vector.py Resolved
Comment thread graphblas/operator.py
semiring_from_string,
# Give binary precedence over this
select_from_string,
indexunary_from_string,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What would one expect to get from e.g. op.from_string("tril")? Should we look for select before indexunary, b/c select is more common?

And, remind me, when we register a new UDF, do we plan to create both versions, or just the opclass that is being registered?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, we should look for select before indexunary. If it exists in select, that is most likely what the user wanted. And if you do op.from_string("rowindex"), you will get the indexunary version because it doesn't exist in select. So anything returning bool will default to select while everything else will be apply.

For UDFs, I haven't decided yet what to do. My initial thought is to register all places where it makes sense. So always register the indexunary, and additionally register with select if it returns a bool.

@eriknw

eriknw commented May 6, 2022

Copy link
Copy Markdown
Member

And sorry about the failed tests. I was stupid. Merge with main for a fix.

@jim22k jim22k mentioned this pull request May 6, 2022
@coveralls

coveralls commented May 6, 2022 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.06%) to 99.697% when pulling d4fe07d on jim22k:apply_indexunary into 3758929 on python-graphblas:main.

@jim22k

jim22k commented May 6, 2022

Copy link
Copy Markdown
Member Author

As far as coverage goes, I know I'm missing several lines of code which get tested once I add UDFs. Until then, I don't want to remove that code or I might forget to add it back in.

@eriknw eriknw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🚀

@jim22k
jim22k merged commit 0b0a912 into python-graphblas:main May 6, 2022
@jim22k
jim22k deleted the apply_indexunary branch July 11, 2022 16:04
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.

3 participants