Thanks to visit codestin.com
Credit goes to github.com

Skip to content

DISCUSS: Namespace for array creation/inspection utils? #24166

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

Closed
seberg opened this issue Jul 12, 2023 · 4 comments
Closed

DISCUSS: Namespace for array creation/inspection utils? #24166

seberg opened this issue Jul 12, 2023 · 4 comments
Labels
Numpy 2.0 API Changes triage review Issue/PR to be discussed at the next triage meeting

Comments

@seberg
Copy link
Member

seberg commented Jul 12, 2023

Can we brainstorm a namespace for array creation/inspection utils? Maybe as part of np.lib.<submodule>, maybe directly np.<submodule>?

Functions I might dump there are:

  • byte_bounds (apparently some use it, and it's an OK function, but not really a general audience one, unlike may_share_memory which I think makes sense at least for teaching).
  • np.core._multiarray_umath._discover_array_parameters: Finds the shape and dtype the same way as np.asarray(), but doesn't create the full array (although it does create some temporaries). Seems to be useful occasionally, and may also be useful to add additional functionality that we do not want in np.asarray().
  • prepare_arrays(*arrays, *, kwarg=None) may be useful. For NEP 50, maybe asarray_or_pyscalar makes just as much sense (one can trivially write that admittedly). @mdhaber liked the idea of having a function that converts multiple arrays to their result type (which could be an option there). I like the idea of clumping asarray calls; opitonally including result_type seems convenient (even if it may not always be ideal as it assumes simple promotion is correct, it is effectively what is often used anyway).
  • normalize_axis_index
  • Probably we can think of more functions to add there or move?

Maybe utils is already a decent name and it just needs to lose some of the weirder functions?

@mattip mattip added the triage review Issue/PR to be discussed at the next triage meeting label Jul 12, 2023
@ngoldbaum
Copy link
Member

How about array_utils?

@rgommers
Copy link
Member

This seems like a reasonable namespace; np.lib.array_utils would work I think.

@mtsokol
Copy link
Member

mtsokol commented Aug 25, 2023

I created a PR that introduces np.lib.array_utils public namespace: #24540

Right now it hosts byte_bounds, normalize_axis_tuple (originally imported from core in np.lib.stride_tricks) and normalize_axis_index (originally imported from core in np.lib.shape_base)

@mtsokol
Copy link
Member

mtsokol commented Dec 1, 2023

Closing as #24540 was merged some time ago.

@mtsokol mtsokol closed this as completed Dec 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Numpy 2.0 API Changes triage review Issue/PR to be discussed at the next triage meeting
Projects
None yet
Development

No branches or pull requests

5 participants