Skip to content

Commit

Permalink
Merge pull request #32 from invrs-io/ndim
Browse files Browse the repository at this point in the history
add ndim property
  • Loading branch information
mfschubert authored May 21, 2024
2 parents acf2737 + 28d4315 commit b773386
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "v0.6.4"
current_version = "v0.7.0"
commit = true
commit_args = "--no-verify"
tag = true
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# totypes - Custom types for topology optimization
`v0.6.4`
`v0.7.0`

## Overview

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/totypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Copyright (c) 2023 The INVRS-IO authors.
"""

__version__ = "v0.6.4"
__version__ = "v0.7.0"
__author__ = "Martin F. Schubert <[email protected]>"

__all__ = ["json_utils", "symmetry", "types"]
Expand Down
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 b773386

Please sign in to comment.