File tree Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Expand file tree Collapse file tree 4 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 66 "HasDType" ,
77 "HasDevice" ,
88 "HasMatrixTranspose" ,
9+ "HasNDim" ,
910 "__version__" ,
1011 "__version_tuple__" ,
1112)
1617 HasDevice ,
1718 HasDType ,
1819 HasMatrixTranspose ,
20+ HasNDim ,
1921)
2022from ._version import version as __version__ , version_tuple as __version_tuple__
Original file line number Diff line number Diff line change 44 "HasDType" ,
55 "HasDevice" ,
66 "HasMatrixTranspose" ,
7+ "HasNDim" ,
78)
89
910from types import ModuleType
@@ -101,6 +102,20 @@ def mT(self) -> Self: # noqa: N802
101102 ...
102103
103104
105+ class HasNDim (Protocol ):
106+ """Protocol for array classes that have a number of dimensions attribute."""
107+
108+ @property
109+ def ndim (self ) -> int :
110+ """Number of array dimensions (axes).
111+
112+ Returns:
113+ int: number of array dimensions (axes).
114+
115+ """
116+ ...
117+
118+
104119class Array (
105120 # ------ Attributes -------
106121 HasDType [DTypeT_co ],
Original file line number Diff line number Diff line change @@ -53,6 +53,13 @@ _: xpt.HasMatrixTranspose = nparr
5353_ : xpt .HasMatrixTranspose = nparr_i32
5454_ : xpt .HasMatrixTranspose = nparr_f32
5555
56+ # =========================================================
57+ # `xpt.HasNDim`
58+
59+ _ : xpt .HasNDim = nparr
60+ _ : xpt .HasNDim = nparr_i32
61+ _ : xpt .HasNDim = nparr_f32
62+
5663# =========================================================
5764# `xpt.Array`
5865
Original file line number Diff line number Diff line change @@ -61,6 +61,14 @@ _: xpt.HasMatrixTranspose = nparr_i32
6161_ : xpt .HasMatrixTranspose = nparr_f32
6262_ : xpt .HasMatrixTranspose = nparr_b
6363
64+ # =========================================================
65+ # `xpt.HasNDim`
66+
67+ _ : xpt .HasNDim = nparr
68+ _ : xpt .HasNDim = nparr_i32
69+ _ : xpt .HasNDim = nparr_f32
70+ _ : xpt .HasNDim = nparr_b
71+
6472# =========================================================
6573# `xpt.Array`
6674
You can’t perform that action at this time.
0 commit comments