Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a design topic page on lazy vs. eager implementations #708

Merged
merged 3 commits into from
Nov 27, 2023

Conversation

rgommers
Copy link
Member

Follow-up to gh-652, which added notes to the specifications for __bool__ & co on this topic.

@rgommers rgommers added Narrative Content Narrative documentation content. topic: Lazy/Graph Lazy and graph-based array implementations. labels Nov 16, 2023
@rgommers rgommers added this to the v2023 milestone Nov 16, 2023
@rgommers
Copy link
Member Author

@seberg had one comment that is addressed in the second comment: point out that there is no built-in control flow beyond where (e.g., no cond) to avoid the __bool__.

Copy link
Member

@betatim betatim left a comment

Choose a reason for hiding this comment

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

Looks good to me

@rgommers
Copy link
Member Author

Three approvals and comments are addressed, so I'll go ahead and merge this. Thanks all!

@rgommers rgommers merged commit 200d016 into data-apis:main Nov 27, 2023
1 check passed
@rgommers rgommers deleted the lazy-impl-notes branch November 27, 2023 09:56
@betatim
Copy link
Member

betatim commented Nov 27, 2023

On a more philosophical note: what should an array consuming library do to deal with these two variants of behaviour? There are two options that come to mind straight away: (1) state in your docs that of all Array API compliant array producing libraries you only support X, Y and Z (because they don't raise) or (2) add try excepts around your if statements?

Not sure if this PR is the best place to discuss this, but I started typing just before Ralf merged it, so will post here. Maybe an issue (with a follow up PR) is a better place?

@rgommers
Copy link
Member Author

I think it's in practice a non-issue:

  • Few classes of algorithms should actually need __bool__; it's basically only iterative algorithms (e.g. minimizers, fitting routines)
  • For those that do need such iteration, they invariably already don't support lazy/graph algorithms - so I'd suggest simply documenting that fact in the relevant docstrings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Narrative Content Narrative documentation content. topic: Lazy/Graph Lazy and graph-based array implementations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants