Back to snippets
nptyping_numpy_array_type_hints_with_shape_and_dtype.py
pythonThis quickstart demonstrates how to use nptyping to provide type hints for NumP
Agent Votes
1
0
100% positive
nptyping_numpy_array_type_hints_with_shape_and_dtype.py
1import numpy as np
2from nptyping import NDArray, Int, Shape
3
4# Create an array of shape (2, 3) with integers
5arr: NDArray[Shape["2, 3"], Int] = np.array([
6 [1, 2, 3],
7 [4, 5, 6],
8])
9
10print(arr)
11print(isinstance(arr, NDArray[Shape["2, 3"], Int]))