From: Zbigniew Jędrzejewski-S. <zb...@in...> - 2014-04-01 21:11:44
|
Hi, Since this is my first post to the list, let me start with an introduction: I work in the Computational and Experimental Neuroplasticity Laboratory directed by dr. Avrama Blackwell. We are currently using a MOOSE model created in Python to fit model parameters to experimental data registered in the lab, with promising results. Following patches allow the MOOSE module to be used from Python 3. They are based on the buildQ branch. Just the module is modified, the GUI parts are still Python 2 only. The following approach is taken: code is tweaked to use a common subset of Python 2 and 3. More specifically, it is made compatible with Python 2.7 and Python 3.3 or later. In a few unavoidable places, like the module initialization in the C++ code, separate branches in #ifdefs are used. In the Python part, some compatiblity imports (in _compat.py) are used to "wrap" the remaining differences. This (using the exact same code under both Python 2 and 3) seems to be nicest way to do the conversion. I haven't done very extensive testing, but at least our model seems to return identical results under Python 2 and 3. I hope posting patches to the mailing list the proper way to submit changes... If no, please let me know. Regards, Zbigniew Jędrzejewski-Szmek Zbigniew Jędrzejewski-Szmek (19): Add gitignore Declare that deprecated Numpy API will not be used Fix warnings about deprecated cast to char* Use pkg-config for Python compliation flags Makefile: simplify detection of python flags Fix compilation under Python 3 Convert to print() Apply has_key fixer Convert to modern raise syntax Apply except fixer Remove some unnecessary .keys() and list() calls Convert to incremental zip, map, filter Add compatiblity layer for basestr and unicode Remove unused import Apply imports fixer Convert to relative imports Remove old separate Python 3 code Make sure classes have __module__ set Add missing space in output .gitignore | 7 + Makefile | 31 +-- gui/shell.py | 2 +- pymoose/ematrix.cpp | 18 +- pymoose/melement.cpp | 2 + pymoose/mfield.cpp | 2 + pymoose/moosemodule.cpp | 38 +++- pymoose/moosemodule.h | 2 + python/moose/_compat.py | 5 + python/moose/alternate.py | 31 +-- python/moose/graphutil.py | 4 +- python/moose/hdfutil.py | 45 ++-- python/moose/moose.py | 38 ++-- python/moose/moose_py3k.py | 249 --------------------- python/moose/mtypes.py | 5 +- python/moose/multiscale/core/mumbl.py | 14 +- python/moose/multiscale/core/simulator.py | 6 +- python/moose/multiscale/core/stimulus.py | 4 +- python/moose/multiscale/core/types.py | 9 +- python/moose/multiscale/helper/graph_methods.py | 4 +- python/moose/multiscale/helper/moose_methods.py | 9 +- .../neuroml/v1.8/GranuleCell/FvsI_Granule98.py | 5 +- .../models/neuroml/v1.8/GranuleCell/Granule98.py | 7 +- .../neuroml/v1.8/GranuleCell/Granule98_hsolve.py | 9 +- .../moose/multiscale/multi_bhalla/diffusionOnly.py | 21 +- python/moose/multiscale/multi_bhalla/lm2.py | 7 +- python/moose/multiscale/multi_bhalla/loadMulti.py | 53 ++--- python/moose/multiscale/multi_bhalla/minimal.py | 3 +- python/moose/multiscale/multi_bhalla/runcell18.py | 16 +- python/moose/multiscale/multi_bhalla/x_compt.py | 3 +- python/moose/multiscale/parser/ChannelML.py | 12 +- python/moose/multiscale/parser/MorphML.py | 6 +- python/moose/multiscale/parser/NetworkML.py | 9 +- python/moose/multiscale/parser/NeuroML.py | 6 +- python/moose/multiscale/parser/parser.py | 2 +- python/moose/multiscale/parser/utils.py | 3 +- python/moose/neuroml/ChannelML.py | 27 +-- python/moose/neuroml/MorphML.py | 33 +-- python/moose/neuroml/NetworkML.py | 23 +- python/moose/neuroml/NeuroML.py | 13 +- python/moose/neuroml/utils.py | 13 +- python/moose/neuroml2/converter.py | 3 +- python/moose/neuroml2/generated_neuroml.py | 160 ++++++------- python/moose/neuroml2/hhfit.py | 2 +- python/moose/neuroml2/reader.py | 26 ++- python/moose/neuroml2/test_converter.py | 5 +- python/moose/neuroml2/test_hhfit.py | 19 +- python/moose/neuroml2/test_reader.py | 3 +- python/moose/neuroml2/units.py | 5 +- python/moose/recording.py | 10 +- python/moose/utils.py | 58 ++--- python/moose/xmls_to_network/.noweb/main.nw | 6 +- python/moose/xmls_to_network/core/hhfit.py | 2 +- python/moose/xmls_to_network/core/load_multi.py | 49 ++-- python/moose/xmls_to_network/core/multiscale.py | 7 +- .../moose/xmls_to_network/core/neuroml2_parser.py | 174 +++++++------- .../moose/xmls_to_network/core/neuroml_to_moose.py | 31 ++- .../moose/xmls_to_network/helper/graph_methods.py | 4 +- python/moose/xmls_to_network/parser/nml_parser.py | 170 +++++++------- .../generatedNEURON/NEURONUtils/NEURONSimUtils.py | 2 +- .../NeuroMLUtils/NetworkMLHDF5Handler.py | 8 +- .../generatedNEURON/NeuroMLUtils/NetworkMLNet.py | 5 +- .../NeuroMLUtils/NetworkMLSaxHandler.py | 91 ++++---- .../twoNeurons/generatedNEURON/twoNeurons.hoc | 4 +- .../NeuroMLUtils/NetworkMLHDF5Handler.py | 8 +- .../generatedPyNN/NeuroMLUtils/NetworkMLNet.py | 5 +- .../NeuroMLUtils/NetworkMLSaxHandler.py | 85 +++---- .../twoNeurons/generatedPyNN/PyNNUtils/Pop.py | 13 +- .../generatedPyNN/PyNNUtils/PyNNUtils.py | 11 +- 69 files changed, 791 insertions(+), 971 deletions(-) create mode 100644 .gitignore create mode 100644 python/moose/_compat.py delete mode 100644 python/moose/moose_py3k.py -- 1.8.5.3 |