Comments (9)
@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.
from pydstool.
@robclewley, we must replace __cmp__
with __eq__
and __ne__
for Python 3 support, anyway. So I suggest to remove check in _applyStateMap
at all.
from pydstool.
@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?
from pydstool.
@robclewley , I talk about this check:
if num_maps > 1:
# ensure that all the maps are the same for multiple
# simultaneous events that point to the same generator
# (the latter was already verified above)
for mapix in range(1,num_maps):
if epochStateMaps[0] != epochStateMaps[mapix]:
raise RuntimeError("PyDSTool does not yet allow "
"truly simultaneous events that do not point "
"to the same model with the same mapping")
After replacing __cmp__
in EvMapping
, condition (!=) always equals to True
. At least, for 'examples/IF_delaynet_syn.py` example.
from pydstool.
@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 __cmp__
to __eq__
would break this.
from pydstool.
@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: __cmp__
has been removed from Python 3, so this method in EvMapping
ignored and objects are compared by id, so they are not equal.
On Python 2, __cmp__
in this concrete situation returns False
(defString
attributes of mappings differ, so alltrue
return False
- see here). Python 2 converts False
to 0 (__cmp__
must return integer!), which means, that objects are equal, and referred check of mappings results in False
, so RuntimeError is not raised.
from pydstool.
@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 __ne__
will return False
for the identically defined event mappings (they should have the same assignDict
and defString
-- are you saying they don't?) and this if
statement should therefore not result in the error condition. Sorry, I still seem to be missing a step in the logic or what you are proposing!
from pydstool.
@robclewley, if I replace __cmp__
with rich comparison, example starts to fail with RuntimeError on Python 2 too. Because compared EvMapping
objects are really different (they do have diferrent defString
attributes).
So logic is simple.
- If this concrete example ('IF_delaynet_syn.py') should pass, then either comparing, or check is wrong and should be fixed
- If check and comparison are correct, then example must fail and it's current behaviour on Python 2 should be fixed
from pydstool.
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?
from pydstool.
Related Issues (20)
- New release on PyPI HOT 1
- Remove legacy Python 2.x cruft...
- Import of pydstool fails with scipy 1.4.1 HOT 4
- step/pulse current injection shape on HH_model. HOT 3
- Issue using Dopri and Radau ODE Systems
- Using a custom function to find fix points HOT 8
- Pytstool HOT 1
- What to do with a 'Could not find starting point on curve. Stopping continuation.'? HOT 1
- "Cannot convert this QuantSpec to a numeric type" error HOT 8
- Tests broken for me HOT 3
- PyDSTool doesn't fully run on Windows 10 with 64 bits HOT 3
- KeyError 'EP' occurring when plotting nullclines.
- Bug in find_nullclines HOT 2
- serialization of pycont objects HOT 1
- Duffing oscillator with PyCont HOT 5
- Duffing oscillator with PyCont( use HB)
- parser module is removed from python 3.10
- Calcium channel model tutorial import error
- ModuleNotFoundError: No module named 'parser' HOT 3
- ImportError: cannot import name 'int' from 'numpy'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pydstool.