Skip to content

Add Array API inspection utilities - #689

Merged
leofang merged 36 commits into
data-apis:mainfrom
kgryte:inspection-namespace
Feb 14, 2024
Merged

Add Array API inspection utilities#689
leofang merged 36 commits into
data-apis:mainfrom
kgryte:inspection-namespace

Conversation

@kgryte

@kgrytekgryte commented Sep 20, 2023

Copy link
Copy Markdown
Contributor

This PR

@kgrytekgryte added API extension Adds new functions or objects to the API. topic: Device Handling Device handling. labels Sep 20, 2023
@kgrytekgryte added this to the v2023 milestone Sep 20, 2023
Comment threadsrc/array_api_stubs/_draft/info.py
Comment threadsrc/array_api_stubs/_draft/_types.py Outdated
@rgommers

Copy link
Copy Markdown
Member

This looks pretty good to me overall, thanks @kgryte.

Comment threadsrc/array_api_stubs/_draft/_types.py Outdated
Comment threadsrc/array_api_stubs/_draft/_types.py Outdated
@kgryte

Copy link
Copy Markdown
ContributorAuthor

I've updated this PR to use a protocol instead of a data class. I believe this PR should be ready for final review.

@rgommersrgommers 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.

The way this PR is written and without looking at the linked discussions, it's not quite clear to me whether __array_namespace_info__ is an array method or a function in the namespace returned by array.__array_namespace__.

In addition, it could be useful to clarify in the __array_namespace_info__ docs that the returned object from that function/method may be either a namespace or a class; as long as the user can do this:

info=__array_namespace_info__()
info.capabilities()
info.devices()
info.dtypes()
info.default_dtypes()

@rgommers

Copy link
Copy Markdown
Member

The rendered docs look fine, maybe some explanation under Inspection APIs and right above the table of function/method names will help?

image

@rgommers

Copy link
Copy Markdown
Member

IIRC there were a few more things discussed for inclusion in the inspection API:

@kgryte

Copy link
Copy Markdown
ContributorAuthor

IIRC there were a few more things discussed for inclusion in the inspection API

I was planning on submitting follow-up PR(s) to avoid potential bikesheds and avoid piggybacking on this PR, but I can include some of the aforementioned additional capabilities in this PR. I don't have a strong opinion, except wanting to get this in sooner rather than later.

@kgryte

Copy link
Copy Markdown
ContributorAuthor

@rgommers The updated inspection.rst file now renders as

Screenshot 2024-01-25 at 1 55 06 AM

@kgryte

Copy link
Copy Markdown
ContributorAuthor

@rgommers@leofang I believe I have addressed your most recent review comments, and this PR should be ready for another round of review.

Comment threadsrc/array_api_stubs/_draft/info.py Outdated
Comment threadsrc/array_api_stubs/_draft/info.py
Comment threadsrc/array_api_stubs/_draft/info.py

@leofangleofang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM from my perspective. I'm keen to see this PR merged so that we can start addressing follow-up works (ex: #689 (comment)).

Ping @oleksandr-pavlyk for review, due to its relevance 🙂

Comment threadsrc/array_api_stubs/_draft/info.py

@rgommersrgommers 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.

LGTM too now, modulo the one typo.

Comment threadspec/draft/API_specification/inspection.rst Outdated
Comment threadspec/draft/API_specification/inspection.rst Outdated

@oleksandr-pavlykoleksandr-pavlyk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

Comment threadsrc/array_api_stubs/_draft/info.py Outdated

@leofangleofang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Two nits on formatting, but content-wise we're good to go!

Comment threadsrc/array_api_stubs/_draft/info.py Outdated
Comment threadsrc/array_api_stubs/_draft/info.py Outdated
Co-authored-by: Leo Fang <leo80042@gmail.com>
@kgryte

Copy link
Copy Markdown
ContributorAuthor

Thanks, @leofang! Made the updates.

@rgommers I think we are good to go here.

@leofang
leofang merged commit cc11aa3 into data-apis:mainFeb 14, 2024
@leofang

Copy link
Copy Markdown
Contributor

Thanks to Athan for driving this and all for help!

@kgryte
kgryte deleted the inspection-namespace branch February 21, 2024 07:18
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API extensionAdds new functions or objects to the API.topic: Device HandlingDevice handling.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: add a unified inspection API namespace ENH: Should we allow querying certain implementation details

7 participants

@kgryte@rgommers@leofang@asmeurer@jakevdp@oleksandr-pavlyk@BvB93