DiamondLightSource / DiamondLightSource/httomo
Type-hint the data type of numpy/cupy arrays with `np.typing.NDArray` and `cp.typing.NDArray`
- Dominant language
- Python
- Stars
- 10
- Forks
- 5
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
It seems that one can specify the data type expected in a numpy array using this https://numpy.org/devdocs/reference/typing.html#numpy.typing.NDArray, rather than only type hinting a numpy array with `np.ndarray` which is currently done.
In several places we are expecting a specific data type in arrays, so this could be useful in helping us not make mistakes with casting array data types.
Cupy seems to offer this as well; I couldn't find it documented anywhere, but it's definitely there https://github.com/cupy/cupy/pull/6251/files, and seems to work locally for me:
```
>>> import cupy as cp
>>> cp.__version__
'12.2.0'
>>> cp.typing.NDArray
cupy.ndarray[typing.Any, numpy.dtype[+_ScalarType]]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.