8000 ENH: Add a helper function to convert to array or scalar · Issue #8681 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Add a helper function to convert to array or scalar #8681

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
eric-wieser opened this issue Feb 24, 2017 · 3 comments
Closed

ENH: Add a helper function to convert to array or scalar #8681

eric-wieser opened this issue Feb 24, 2017 · 3 comments
Labels
01 - Enhancement 57 - Close? Issues which may be closable unless discussion continued

Comments

@eric-wieser
Copy link
Member

Something so that:

>>> the_func([1, 2])
array([1, 2])
>>> type(_)
np.ndarray
>>> the_func(1)
1
>>> type(_)
np.int32

Can be implemented trivially as

def the_func(x):
    return asanyarray(x)[()]

What should this be called?

  • asanyarray(x, ..., allow_scalar=True)
  • asanyarrayorscalar(x)
@seberg
Copy link
Member
seberg commented Feb 25, 2017

On the C-api side there is a function, something like PyArray_ReturnArray or so, which does this conversion. The indexing is just a hack that comes close to doing the same thing really.

@InessaPawson InessaPawson changed the title Add a helper function to convert to array or scalar ENH: Add a helper function to convert to array or scalar Jan 16, 2023
@InessaPawson InessaPawson added 01 - Enhancement triage review Issue/PR to be discussed at the next triage meeting labels Jan 16, 2023
@mattip
Copy link
Member
mattip commented Feb 8, 2023

I suggest we close this.

@mattip mattip added 57 - Close? Issues which may be closable unless discussion continued and removed triage review Issue/PR to be discussed at the next triage meeting labels Feb 8, 2023
@InessaPawson
Copy link
Member

@eric-wieser I’m going to close this issue as the proposed feature didn’t get support from the NumPy dev team at 2023-02-08 meeting where it was reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - Enhancement 57 - Close? Issues which may be closable unless discussion continued
Projects
None yet
Development

No branches or pull requests

4 participants
0