Conversation
|
Thanks, didn't realize it would be quite this small. Should probably add it to the stubs also? (I know very minimal, and doesn't help with the diff on the other PR.) Maybe we can get this in quickly, then see if there are more small adaptations where |
|
Sure! Right, mypy stubs are missing. |
56177e5 to
b68854d
Compare
| `numpy.long` and `numpy.ulong` have been reintroduced as a direct | ||
| mapping to C's ``long`` and ``unsigned long`` types. |
There was a problem hiding this comment.
"reintroduced" suggests they have the same meaning as before they were removed, but this is not the case.
There was a problem hiding this comment.
Maybe we can just remove it and say: ... added as NumPy integers mapping to C's long and unsigned long. Prior to NumPy 1.24 np.long was an alias to Python's int.
It was actually deprecated at the time already I think. (Ignoring that it was Python long on Python 2, and then actually had the long long meaning in dtype(...), I think it was just int after that.)
There was a problem hiding this comment.
Sure, I updated it accordingly.
numpy/_typing/_char_codes.py
Outdated
| _UIntCodes = Literal["uint", "L", "=L", "<L", ">L"] | ||
| _ULongCodes = Literal["ulong"] |
There was a problem hiding this comment.
| _UIntCodes = Literal["uint", "L", "=L", "<L", ">L"] | |
| _ULongCodes = Literal["ulong"] | |
| _ULongCodes = Literal["ulong", "uint", "L", "=L", "<L", ">L"] |
There was a problem hiding this comment.
I think that "uint" should still be associated with np.uint. I also wanted to make this PR minimal, just reintroduce np.long. WDYT?
There was a problem hiding this comment.
These should be considered as aliases for the same thing, so I don't see why we'd want to give them a different typecode.
There was a problem hiding this comment.
There is a tricky thing with the follow up, but right now, ulong is a correct type code for uint, so renaming it doesn't really matter. Maybe it actually makes sense to make: _UIntCodes = _ULongCodes?
What I am unclear about is what needs to change if we change this to _UIntCodes = _UIntpCodes later. @BvB93 gave a diff in the PR doing that, but it is not quite clear to me that it is complete now.
There was a problem hiding this comment.
I updated it so now:
_ULongCodes = Literal["ulong", "uint", "L", "=L", "<L", ">L"]
_UIntCodes = _ULongCodes(same for int/long)
b68854d to
1560830
Compare
|
Ok, let me put this in. I don't think this is the final word on typing here. Declaring it as an alias only is fine, but only of limited help for now and the alias isn't even used, yet. In practice almost all (maybe even all) places should just use @mtsokol do you want to follow up with that move? I am pretty sure changing what |
Sure! I will take care of it. |
|
Right, as
This might be good to check, yes. There are a number of functions that always return |
|
I think it is safe to say that they should all map to |
Hi! This PR addresses #11093. It skips `np.bool` and `np.long` replacements as both of these names were reintroduced in NumPy 2.0 with a different meaning (numpy/numpy#24922, numpy/numpy#25080). With this change `NPY001` will no longer conflict with `NPY201`. For projects using NumPy 1.x `np.bool` and `np.long` has been deprecated and removed long time ago, and accessing them yields an informative error message.
Connected to #24224.
Hi @seberg,
In this minimal PR I introduced
np.longandnp.ulongonly, without interfering withnp.int_andnp.uint(the latter pair is an alias from now here but they map toNPY_LONG/NPY_ULONGexactly as before).