Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master-v1.7.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
christophe-david committed Jul 1, 2024
2 parents 1d40f7b + a855fd6 commit 50bc36a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/fastoad/openmdao/tests/openmdao_sellar_example/disc1.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ...validity_checker import ValidityDomainChecker


@ValidityDomainChecker({"x": (-1, 1)}) # This validity domain should not apply
@ValidityDomainChecker({"x": (-1, 1), "z": (0, 10)}) # This validity domain should not apply
class Disc1(BasicDisc1):
"""An OpenMDAO component to encapsulate Disc1 discipline"""

Expand All @@ -44,6 +44,6 @@ def setup(self):
self.add_output("y1", val=1.0, desc="variable y1") # for testing output description capture


@ValidityDomainChecker({"x": (0, 1)}) # This validity domain should apply in case 2
@ValidityDomainChecker({"x": (0, 1), "z": (0, 1)}) # This validity domain should apply in case 2
class Disc1Ter(Disc1Bis):
"""Same component with different validity domain."""
4 changes: 4 additions & 0 deletions src/fastoad/openmdao/tests/test_validity_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,7 @@ def test_sellar(caplog):
problem.setup()
problem.run_model()
assert 'Variable "x" out of bound: value [2.] is over upper limit ( 1 )' in caplog.text
assert (
'Variable "z" out of bound: value [5. 2.] m**2 is over upper limit ( 1 m**2 )'
in caplog.text
)
8 changes: 5 additions & 3 deletions src/fastoad/openmdao/validity_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ def check_variables(
) and var.name in limit_definitions:
limit_def = limit_definitions[var.name]
value = convert_units(var.value, var.units, limit_def.units)
if value < limit_def.lower:
if np.any(value < limit_def.lower):
status = ValidityStatus.TOO_LOW
limit = limit_def.lower
elif value > limit_def.upper:
elif np.any(value > limit_def.upper):
status = ValidityStatus.TOO_HIGH
limit = limit_def.upper
else:
Expand Down Expand Up @@ -226,7 +226,9 @@ def log_records(records: List[CheckRecord]):
for record in records:
if record.status != ValidityStatus.OK:
logger = logging.getLogger(record.logger_name)
limit_text = "under lower" if record.value < record.limit_value else "over upper"
limit_text = (
"under lower" if np.any(record.value < record.limit_value) else "over upper"
)
logger.warning(
'Variable "%s" out of bound: value %s%s is %s limit ( %s%s ) in file %s',
record.variable_name,
Expand Down

0 comments on commit 50bc36a

Please sign in to comment.