-
Notifications
You must be signed in to change notification settings - Fork 65
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
EvMapping: broken comparison #29
Comments
@z2v Thanks for the info. I don't have time to study this in detail right now, but if the changes are limited in scope, as they appear to be, can you make a suggestion on which to adjust? Off the top of my head, I don't know of a reason to care which way it is changed. Otherwise, I can study this in a couple of weeks' time. |
@robclewley, we must replace |
@z2v OK, but which check are you referring to in HybridModel._applyStateMap? The only one I see is the check for simultaneous events, which is important to trap. Did I miss it? |
@robclewley , I talk about this check:
After replacing |
@z2v That's what I thought. This might need closer investigation, then, because that check is important. Without it, rare cases where there are simultaneous events will go unnoticed and could result in spurious numerical results. I don't understand how the simple switch from |
@robclewley, ok. I'll try to describe, what I've found. In current state, 'examples/IF_delaynet_syn.py' example passes on Python 2 and fails on Python 3 with RuntimeError due to referred check. The reason is: On Python 2, |
@z2v I understand so far about the current state. But you added the rich comparisons in the patch and said that still leads to a problem. Why do the rich comparison methods not ensure the desired comparison? In the usual ("everything OK") case, the new |
@robclewley, if I replace So logic is simple.
|
There is indeed something wrong with the logical principle of this check (beyond the technical issue of cmp vs eq implementation). Currently, later in the method, there's a warning from the previous hybrid segment if more than one event was found (provided verboselevel > 0) and that should take care of it for now. (In fact, an extra clause to make that an error for verboselevel > 1 would be good.) When this EvMapping comparison is reached, there may indeed be multiple EvMappings and they have not been correctly populated: they should only be compared if they are associated with activated events at this timestep. So, this test is spurious and can be commented out. Please leave a note in the code to address it later, preferably with a link to this discussion? |
Commented out check in `PyDSTool\Model.py` needs to be investigated deeper. See comment in code and discussion in issue robclewley#29.
EvMapping
object from PyDSTool/ModelTools.py defines__cmp__
method. This method returnsTrue
orFalse
. That contradicts to Python 2 demands (Python 2 data model - method must return integer, and 0 means 'eqaulity'). As a result, 'equality' and 'inequality' ofEvMapping
objects are reverted: when__cmp__
returnsFalse
, this means 'objects are equal' (int(False) == 0
).Replacing
__cmp__
with rich comparison operators (a must for Python 3, see patch below) leads to 'RuntimeError' in_applyStateMap
method ofHybridModel
object (Model.py, lines 2205-2207) both on Python 2 and Python 3. To get error, apply patchand run 'examples/IF_delaynet_syn.py'.
So either 'equatlity' checking in
EvMapping
, or check in_applyStateMap
(or both) shoud be adjusted.The text was updated successfully, but these errors were encountered: