-
Notifications
You must be signed in to change notification settings - Fork 439
ValueError("Time steps T
must match sampling time"
#332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you attach a code snippet that generates the error? This check is done in the discrete time portion of the code and so a small error between Also, can you indicate which version of |
My "control" version is 0.8.2, Python version 3.7.3 (IPython 7.6.1) Windows 10 (64 bits) import numpy as np T[2]-T[1] T[3]-T[2] T[4]-T[3] So, if we call timeresp.py with T[3:] as our time steps in simulation, line 265 "dt = T[1] - T[0]" will yield dt = 1.9999999999999995e-06, but sys.dt should be 2e-6. Subsequently, line 337 will raise the ValueError. If simulation time uses T, or T[1:], or T[2:] will have no problem! |
It seems the problem goes away by changing line 337 in timeresp.py to: |
Thanks for the extra info @bj2sn. A fix will be a bit more complicated because the discrete time simulation routines allow you to specify a sample time for the simulation that is a multiple of the sampling time for the system. So, for example, you can have that Will put this on my list of things to fix. |
Fixed in PR #356. |
Got this error when using timeresp.py. Checked the source code, I think the problem is at line 337-338:
if dt < sys.dt:
raise ValueError("Time steps
T
must match sampling time")It will be better to use the following, since float rounding error can be smaller or larger:
if abs(dt-sys.dt) > 1e-5:
The text was updated successfully, but these errors were encountered: