Skip to content

Commit

Permalink
add ndim property
Browse files Browse the repository at this point in the history
  • Loading branch information
mfschubert committed May 21, 2024
1 parent acf2737 commit cf8ccb4
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/totypes/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,14 @@ def __post_init__(self) -> None:

@property
def shape(self) -> Tuple[int, ...]:
"""Returns the shape of the array."""
"""Return the shape of the array."""
return jnp.shape(self.array) # type: ignore[no-any-return]

@property
def ndim(self) -> int:
"""Return the number of dimensions of the array."""
return int(jnp.ndim(self.array))


def _flatten_bounded_array(
bounded_array: BoundedArray,
Expand Down Expand Up @@ -252,9 +257,14 @@ def __post_init__(self) -> None:

@property
def shape(self) -> Tuple[int, ...]:
"""Returns the shape of the array."""
"""Return the shape of the array."""
return jnp.shape(self.array) # type: ignore[no-any-return]

@property
def ndim(self) -> int:
"""Return the number of dimensions of the array."""
return int(jnp.ndim(self.array))


def _flatten_density_2d(
density: Density2DArray,
Expand Down

0 comments on commit cf8ccb4

Please sign in to comment.