dtype.__repr__: prefer __name__ for user-defined types.#28250
dtype.__repr__: prefer __name__ for user-defined types.#28250charris merged 5 commits intonumpy:mainfrom
Conversation
|
Could use a release note, as it is a behavior change. |
|
Added a release note and a test. The test doesn't really cover the motivating issue here, as |
|
There’s also the scaled float test dtype using the new dtype system. I want to add numpy-user-dtypes as a test-only dependency to make it easier to test stuff like this. |
|
The behavior change seems fine to me and reads like what the code intended beyond that no one expected someone to write a user dtype set up like bfloat16. |
|
Close/reopen. The test failure looks unrelated, but I would like to know what is going on. |
|
@jakevdp Could you try rebasing on current master to see if that fixes the build failure on CircleCI? |
The current approach can result in a misleading repr() for user-defined dtypes. For example, a bfloat16 scalar type that inherits from np.number and sets dtype.kind='f' will be displayed as dtype('float16'). We can circumvent this by handling user-defined dtypes first.
|
rebased |
|
@jakevdp Thanks, that fixed the build. There was still an undefined reference, which I have fixed. |
|
Thanks @jakevdp . |
The current approach can result in a misleading
repr()for user-defined dtypes. For example, abfloat16scalar type that inherits fromnp.numberand setsdtype.kind='f'will be displayed asdtype('float16')rather thandtype(bfloat16). We can circumvent this by handling user-defined dtypes first.