Skip to content

Update API specification for creation and manipulation functions #167

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

Merged
merged 10 commits into from
Apr 27, 2021

Conversation

rgommers
Copy link
Member

@rgommers rgommers commented Apr 20, 2021

Addresses a lot of detailed comments, mostly on function signatures and default dtypes.

Closes gh-85
Closes gh-107
Closes gh-151


- **dtype**: _Optional\[ <dtype> ]_

- output array data type. If `dtype` is `None`, the output array data type must be the default floating-point data type. Default: `None`.
- output array data type. If `dtype` is `None`, the output array data type must be inferred from `start`, `stop` and `step`. If those are all integers, the output array dtype must be the default integer dtype; if one or more have type `float`, then the output array dtype must be the default floating-point data type. Default: `None`.
Copy link
Member

Choose a reason for hiding this comment

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

Does the spec talk about "default integer dtype" anywhere? It says

A conforming implementation of the array API standard must define a default floating-point data type (either float32 or float64), as well as a default data type for an array index (either int32 or int64).

Copy link
Contributor

Choose a reason for hiding this comment

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

No, not at the moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

It does, in the "data types" section. My last commit extends that paragraph.

Copy link
Member Author

Choose a reason for hiding this comment

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

Meh, wording - that was intended as "default integer dtype" I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated that section. A default dtype for indexing arrays doesn't make sense to me; only the values indexing accepts are meaningful (can it exceed 32-bit). But given that we don't have advanced indexing, even that doesn't really make sense. Why do we need this at all?

Copy link
Member Author

Choose a reason for hiding this comment

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

This is what take can be used for, but we don't have it. On the other hand, if we'd be able to add take, why not just add 1-D integer array indexing?

Copy link
Member Author

Choose a reason for hiding this comment

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

It would be easier to use take to be able to mark it as problematic for shape inference. Worth considering.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed.

Copy link
Member

Choose a reason for hiding this comment

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

It's also relevant for integer indexing. A 32-bit integer index type limits the max size of a dimension.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's more a "how large can your array be" limitation than an indexing thing though.

@asmeurer
Copy link
Member

From a grep, broadcast_to also takes the shape parameter as positional-only.

@rgommers
Copy link
Member Author

From a grep, broadcast_to also takes the shape parameter as positional-only.

Thanks, included now.

Address a review comment; makes it consistent with other functions
using `shape`.
@rgommers rgommers added API change Changes to existing functions or objects in the API. Maintenance Bug fix, typo fix, or general maintenance. labels Apr 20, 2021
@leofang
Copy link
Contributor

leofang commented Apr 27, 2021

LGTM. Let's resolve the conflict.

@rgommers
Copy link
Member Author

Thanks Leo. Okay, let's get this in then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API change Changes to existing functions or objects in the API. Maintenance Bug fix, typo fix, or general maintenance.
Projects
None yet
4 participants