Misleading API behavior with respect to `valid_range` and `limits` when adding inward or outward
Description
When using the add_inward
or add_outward
method in the System class to define a variable with specific limits, through System.add_iwnard(limits=...)
, I noticed that the API does not behave as expected. Am I missing something @etienne.lac?
The same behavior is observed whith: System.add_iwnard(valid_range=...)
Code to reproduce
from cosapp.systems import System
class Foo(System):
def setup(self):
self.add_inward(
'a',
limits=[0,1], # Notice the limits set here
out_of_limits_comment='the value is out of limits'
)
foo = Foo('foo')
foo.a = -1
foo.run_once()
>>> # No output is displayed in stdout.
Even after explicitly setting the logger to monitor system resolution at its highest level (LogLevel.DEBUG
) using the following code:
from cosapp.utils import LogLevel, set_log
set_log(level=LogLevel.DEBUG)
no ValueError
or Warnings
were raised. Below is the stdout output:
System <foo - Foo> is the execution master.
Start setup_run recursive calls.
Call foo.setup_run
Call foo.compute_before
Call foo.compute
Start clean_run recursive calls.
Call foo.clean_run
Compute calls for foo: 1
Expected Behavior:
Given that I've set the variable a with a limit between [0, 1], I would expect cosapp to raise a ValueError
, or a Warning
or capture this limit exceedance via the logger when I assign a value (-1 in this case) that's outside this range.