Skip to content

Commit

Permalink
Merge pull request #29 from invrs-io/compile
Browse files Browse the repository at this point in the history
Check bounds during compile
  • Loading branch information
mfschubert authored Feb 23, 2024
2 parents e112983 + 2edcf85 commit ceabae5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 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.1"
current_version = "v0.6.2"
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.1`
`v0.6.2`

## 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.1"
version = "v0.6.2"
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.1"
__version__ = "v0.6.2"
__author__ = "Martin F. Schubert <[email protected]>"

__all__ = ["json_utils", "symmetry", "types"]
Expand Down
17 changes: 9 additions & 8 deletions src/totypes/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,15 @@ def __post_init__(self) -> None:
if self.upper_bound is not None and self.lower_bound is not None:
invalid_bounds = self.lower_bound >= self.upper_bound
is_array = isinstance(invalid_bounds, (jnp.ndarray, onp.ndarray))
if (
is_array
and invalid_bounds.any() # type: ignore[union-attr]
or (not is_array and invalid_bounds)
):
raise ValueError(
"`upper_bound` must be strictly greater than `lower_bound`."
)
with jax.ensure_compile_time_eval():
if (
is_array
and invalid_bounds.any() # type: ignore[union-attr]
or (not is_array and invalid_bounds)
):
raise ValueError(
"`upper_bound` must be strictly greater than `lower_bound`."
)

@property
def shape(self) -> Tuple[int, ...]:
Expand Down

0 comments on commit ceabae5

Please sign in to comment.