From cf8ccb45d177c48aca2dda3f74ba6af7cbf0e981 Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Tue, 21 May 2024 12:10:57 -0700 Subject: [PATCH 1/2] add ndim property --- src/totypes/types.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/totypes/types.py b/src/totypes/types.py index f17c57e..136fe89 100644 --- a/src/totypes/types.py +++ b/src/totypes/types.py @@ -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, @@ -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, From 28d431569c2a237681b37a8383ba2a65c08fcdd6 Mon Sep 17 00:00:00 2001 From: Martin Schubert Date: Tue, 21 May 2024 12:13:16 -0700 Subject: [PATCH 2/2] Version updated from v0.6.4 to v0.7.0 --- .bumpversion.toml | 2 +- README.md | 2 +- pyproject.toml | 2 +- src/totypes/__init__.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.toml b/.bumpversion.toml index 1398bf1..52acb77 100644 --- a/.bumpversion.toml +++ b/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "v0.6.4" +current_version = "v0.7.0" commit = true commit_args = "--no-verify" tag = true diff --git a/README.md b/README.md index 0a25c7e..71c26d3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # totypes - Custom types for topology optimization -`v0.6.4` +`v0.7.0` ## Overview diff --git a/pyproject.toml b/pyproject.toml index e7869f9..3559d69 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "totypes" -version = "v0.6.4" +version = "v0.7.0" description = "Custom datatypes useful in a topology optimization context" keywords = ["topology", "optimization", "jax", "inverse design"] readme = "README.md" diff --git a/src/totypes/__init__.py b/src/totypes/__init__.py index 68c13b7..e8a4782 100644 --- a/src/totypes/__init__.py +++ b/src/totypes/__init__.py @@ -3,7 +3,7 @@ Copyright (c) 2023 The INVRS-IO authors. """ -__version__ = "v0.6.4" +__version__ = "v0.7.0" __author__ = "Martin F. Schubert " __all__ = ["json_utils", "symmetry", "types"]