mhe / pynrrd

Simple pure-python module for reading and writing nrrd files.
https://pynrrd.readthedocs.io/
MIT License
116 stars 51 forks source link

Replace nptyping with numpy.typing #154

Closed eleftherioszisis closed 1 month ago

eleftherioszisis commented 1 month ago

Fixes #152, #153

I replaced nptyping NDArray occurrences with numpy.typing ones.

I am not sure if it's possible to specify shape restrictions without forcing the package to require python>=3.9 so that type subscription is available and things like np.ndarray[Literal[1], np.dtype[Any]] can be declared.

Note that numpy.typing.NDArray is a type alias for np.ndarray[Any, np.dtype[+ScalarType]] where ScalarType contains the following types:

(int,
 float,
 complex,
 bool,
 bytes,
 str,
 memoryview,
 numpy.bool_,
 numpy.complex64,
 numpy.complex128,
 numpy.complex256,
 numpy.float16,
 numpy.float32,
 numpy.float64,
 numpy.float128,
 numpy.int8,
 numpy.int16,
 numpy.int32,
 numpy.int64,
 numpy.longlong,
 numpy.timedelta64,
 numpy.datetime64,
 numpy.object_,
 numpy.bytes_,
 numpy.str_,
 numpy.uint8,
 numpy.uint16,
 numpy.uint32,
 numpy.uint64,
 numpy.ulonglong,
 numpy.void)

Although it is simpler to use it as it is, please let me know if a more permissible NDArray[Any] is preferred.

eleftherioszisis commented 4 weeks ago

@addisonElliott would it be possible to schedule a release at a convenient time? This would allow us to update our tools. Thank you very much in advance!

addisonElliott commented 3 weeks ago

Sorry, I've been meaning to find the time to do that. Hopefully this weekend or next week. I have another feature I want to merge in and do a minor release.

I was going to do a major release, but I think it's a minor enough change that a minor will suffice.