Cross-kind casting in asarray()
See original GitHub issueShould asarray() allow arbitrary casting between dtypes if you call asarray(x, dtype=dtype)
? It isn’t really clear in the spec if, e.g., asarray(x, dtype=bool)
should be required to work if x is an integer or float array, or asarray(x, dtype=float64)
if x is integer, and so on. My feeling is that it definitely should work if dtype
is a promotable type from x.dtype
, but I don’t know if casts that aren’t required to promote should also be required to work.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
numpy.asarray — NumPy v1.24 Manual
Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__...
Read more >numpy.asarray() - JAX documentation - Read the Docs
LAX-backend implementation of numpy.asarray() . This function will create arrays on JAX's default device. For control of the device placement of data, see...
Read more >Test suite for the PyData Array APIs standard - GitHub
Testing asarray() works with scalars (and nested sequences of scalars) is fundamental to testing that it works with arrays, as said arrays can...
Read more >numpy.asarray() in Python - GeeksforGeeks
numpy.asarray() function is used when we want to convert input to an array. Input can be lists, lists of tuples, tuples, tuples of...
Read more >What is the difference between np.array() and np.asarray()?
asarray() with the example: np.array(): Convert input data (list, tuple, array, or other sequence type) to an ndarray and copies the input data ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh yeah you are right about the _like functions (those always confuse me tbh because they seem rather pointless, but that’s neither here nor there).
@asmeurer I am not seeing how the
*_like
functions are affected by cross-kind casting, as discussed in this issue. Maybe I am missing something, but the*_like
functions don’t perform casting; the data of the input array is not touched.