[Test Failure] test_ode.py::test_random_network
madelynshapiro opened this issue · comments
Description:
./tests/test_ode.py::test_random_network Failed: [undefined]TypeError: GeneralNetworkedODE.ode_equations() missing 1 required positional argument: 'u'
Full Testing Log
TestFailureMessage (click to expand)
./tests/test_ode.py::test_random_network Failed: [undefined]TypeError: GeneralNetworkedODE.ode_equations() missing 1 required positional argument: 'u'
Falsifying example: test_random_network(
nAgents=1,
nCouplings=0,
nu=0,
batchsize=1,
bias='additive',
system=neuromancer.dynamics.ode.GeneralNetworkedODE,
)
@given(st.integers(1, 100),
> st.integers(0, 1000),
st.integers(0, 100),
st.integers(1, 500),
st.sampled_from(bias),
st.sampled_from(ode_networked_systems))
tests/test_ode.py:52:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
tests/test_ode.py:80: in test_random_network
y = ode(x)
.conda/lib/python3.10/site-packages/torch/nn/modules/module.py:1501: in _call_impl
return forward_call(*args, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = GeneralNetworkedODE(
(agents): ModuleList(
(0): SourceSink()
)
(couplings): ModuleList()
)
x = tensor([[0.3018]]), args = ()
def forward(self, x, *args):
assert len(x.shape) == 2
> return self.ode_equations(x, *args)
E TypeError: GeneralNetworkedODE.ode_equations() missing 1 required positional argument: 'u'
E Falsifying example: test_random_network(
E nAgents=1,
E nCouplings=0,
E nu=0,
E batchsize=1,
E bias='additive',
E system=neuromancer.dynamics.ode.GeneralNetworkedODE,
E )
src/neuromancer/dynamics/ode.py:24: TypeError
Context
The 1.4.1 release (#63):
- modified
ode.py
API for non-autonomous systems (DuffingParam
,TwoTankParam
,LorenzControl
,CSTR_Param
, &VanDerPolControl
) so that theode_equations
method acceptsx
andu
as two separate mandatory arguments instead of a single stacked tensor. - test coverage in
test_ode.py::test_ode_nonauto_param_shape
was updated to use the new API.
In response to issue #76, hotfix 22ebe07:
- applied the same API change to networked systems (
GeneralNetworkedODE
) to support RC networks. - test coverage in
test_ode.py::test_random_network
was not updated.
Main problem: Backwards compatibility of ODEs API in 1.4.1
For the blocks interface, the Block
base class handles either input format (stacked x
or separate x, *args
.) The dynamics module needs equivalent handling to keep non-autonomous and networked systems backwards-compatible.
Proposed Fix
- Update function signature for
ode_equations
so thatu
is an optional arg, defaultNone
- For non-autonomous systems: If
u is None
andx.shape[-1] == self.nx + self.nu
: split into separatex, u
tensors and issue a warning to the user about the API update before proceeding with the rest of the function. - For networked systems: wrap a conditional around the concatenation of
x, u
to check ifu is not None
Status
PR in progress
TODO:
- Implement proposed fix described above
- Update test coverage for both current API + backwards compatibility
I fixed this issue by supporting *args inputs in ode_equations. The proposed solution is in the development branch.
resolver in the most recent PR