ENH: implement __complex__ - #7229
Conversation
|
About time, someone does this. I guess it already works for scalars (or maybe they get forwarded to ndarray)? Could you move this to the identical definitions for |
|
Needs release note. |
|
It already works for scalars. I guess I could put it over with I've updated the PR to include a comment in the release notes and to handle object or string dtypes as well as to improved the error message provided when conversion cannot be done. Supporting strings is mostly about completeness. Since it works for the scalar type it may as well work for the array type too. |
|
Did not look at the code yet. Leaving it where it is sounds fine, since No conversion from string please. Also I don't think it exists for the
|
|
I'll drop the string conversion then. Mind that your example fails because |
|
Updated. |
|
☔ The latest upstream changes (presumably #7296) made this pull request unmergeable. Please resolve the merge conflicts. |
|
rebased. |
|
Close and reopen to try to trigger appveyor. |
|
Hmmm, whats wrong with AppVoyer? I will try the close + reopen again. @ewmoore if you have some time, one thing that is missing are tests the failure cases as well, those would be good. Otherwise LGTM. |
|
Hmm, didn't help, but I very much doubt this has anything to do with the code, so.... |
There was a problem hiding this comment.
Oh, would be nice if you can increase the indent here.
|
The close, reopen trick doesn't work with appveyor. |
|
☔ The latest upstream changes (presumably #7373) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Rebased, comments addressed. |
|
Could you still add a test for the failure cases like more then 1 element in the array, and maybe some weird void type conversion to scalar? |
|
Tests added. |
|
I can squash this if you'd prefer. |
|
Squashing is nice, but I can live with three reasonably described commits. Thanks a lot Eric! |
Fixes gh-2491.
There is still some asymmetry here. Calling
float()orcomplex()on anp.string_scalar will try to convert the string to a float or a complex. But this still doesn't work forsize = 1arrays.