Add `__complex__` to array object
See original GitHub issueWe currently have respective dunder methods for bool/ints/floats, so if just for consistency x.__complex__()
seems nice. Personally I’ve found the other methods hella useful for array-api-tests
and Hypothesis, so imagine this will prove useful too.
I think we’d want to specify this just for complex-valued floating-point arrays, and adopters can choose to support real-valud float arrays if-and-however they so wish.
Issue Analytics
- State:
- Created a year ago
- Comments:14 (14 by maintainers)
Top Results From Across the Web
javascript - Add complex array of objects into another object
How can I have only unique type1 , type2 objects inside final array. const myTransform2 = arr => { // set-up empty arrays...
Read more >Array methods - The Modern JavaScript Tutorial
Arrays provide a lot of methods. To make things easier, in this chapter they are split into groups. Add/remove items.
Read more >Array functions - Make
Use the key argument to access properties inside complex objects. To access nested properties, use dot notation. The first item in an array...
Read more >numpy.ndarray — NumPy v1.24 Manual
An array object represents a multidimensional, homogeneous array of ... Insert scalar into an array (scalar is cast to array's dtype, if possible)....
Read more >CodeChallenge/Manipulating Complex Objects.md at master
This is an array of objects and the object has various pieces of metadata ... Add artist and title strings , release_year number...
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
I think the story for
__complex__
is different. In other places, we strive to avoid complex-to-real conversions, but here with__complex__
the direction is different (whatever-to-complex), so I am less concerned.IMO it must work for all 0-D inputs covered by the standard (numerical and boolean). Two reasons:
real_arr.astype(complex_dtype)
. That I think must work? (This is not promotion: there are no mixed dtypes involved.)I could see a point against boolean, but it seems no worse than for int/float, so unless that is exclused there, it should not be here I think.