myokit 1.33.9__py3-none-any.whl → 1.35.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- myokit/__init__.py +9 -36
- myokit/__main__.py +76 -142
- myokit/_aux.py +62 -16
- myokit/_bin/example.mmt +1 -2
- myokit/_bin/install-win/menu.json +7 -7
- myokit/_config.py +22 -31
- myokit/_datablock.py +30 -74
- myokit/_datalog.py +49 -72
- myokit/_err.py +25 -24
- myokit/_expressions.py +50 -68
- myokit/_io.py +15 -27
- myokit/_model_api.py +453 -249
- myokit/_myokit_version.py +1 -5
- myokit/_parsing.py +38 -44
- myokit/_progress.py +5 -8
- myokit/_protocol.py +99 -9
- myokit/_sim/__init__.py +7 -24
- myokit/_sim/cable.c +6 -8
- myokit/_sim/cable.py +6 -8
- myokit/_sim/cmodel.h +125 -70
- myokit/_sim/cmodel.py +12 -14
- myokit/_sim/compiler.py +1 -4
- myokit/_sim/cvodessim.c +196 -118
- myokit/_sim/cvodessim.py +130 -103
- myokit/_sim/differential.hpp +4 -4
- myokit/_sim/fiber_tissue.c +4 -8
- myokit/_sim/fiber_tissue.py +11 -13
- myokit/_sim/jacobian.cpp +2 -2
- myokit/_sim/jacobian.py +11 -8
- myokit/_sim/mcl.h +53 -55
- myokit/_sim/opencl.py +21 -27
- myokit/_sim/openclsim.c +3 -7
- myokit/_sim/openclsim.cl +3 -3
- myokit/_sim/openclsim.py +49 -40
- myokit/_sim/pacing.h +36 -16
- myokit/_sim/rhs.c +6 -13
- myokit/_sim/rhs.py +5 -14
- myokit/_sim/sundials.py +1 -4
- myokit/_system.py +10 -16
- myokit/_unit.py +4 -13
- myokit/float.py +0 -3
- myokit/formats/__init__.py +8 -10
- myokit/formats/ansic/__init__.py +0 -3
- myokit/formats/ansic/_ewriter.py +2 -4
- myokit/formats/ansic/_exporter.py +1 -4
- myokit/formats/ansic/template/cable.c +4 -4
- myokit/formats/ansic/template/euler.c +5 -5
- myokit/formats/ansic/template/sim.c +6 -6
- myokit/formats/axon/__init__.py +1 -3
- myokit/formats/axon/_abf.py +12 -17
- myokit/formats/axon/_atf.py +5 -6
- myokit/formats/axon/_importer.py +0 -3
- myokit/formats/cellml/__init__.py +0 -3
- myokit/formats/cellml/_ewriter.py +3 -6
- myokit/formats/cellml/_exporter.py +3 -6
- myokit/formats/cellml/_importer.py +1 -4
- myokit/formats/cellml/v1/__init__.py +0 -4
- myokit/formats/cellml/v1/_api.py +8 -11
- myokit/formats/cellml/v1/_parser.py +2 -5
- myokit/formats/cellml/v1/_writer.py +2 -11
- myokit/formats/cellml/v2/__init__.py +0 -3
- myokit/formats/cellml/v2/_api.py +8 -17
- myokit/formats/cellml/v2/_parser.py +2 -5
- myokit/formats/cellml/v2/_writer.py +1 -4
- myokit/formats/channelml/__init__.py +0 -3
- myokit/formats/channelml/_importer.py +11 -21
- myokit/formats/cpp/__init__.py +1 -3
- myokit/formats/cpp/_ewriter.py +0 -3
- myokit/formats/cuda/__init__.py +0 -3
- myokit/formats/cuda/_ewriter.py +2 -4
- myokit/formats/cuda/_exporter.py +0 -3
- myokit/formats/cuda/template/kernel.cu +8 -5
- myokit/formats/easyml/__init__.py +0 -3
- myokit/formats/easyml/_ewriter.py +9 -11
- myokit/formats/easyml/_exporter.py +2 -5
- myokit/formats/html/__init__.py +0 -3
- myokit/formats/html/_exporter.py +0 -3
- myokit/formats/html/_flatten.py +5 -21
- myokit/formats/latex/__init__.py +0 -3
- myokit/formats/latex/_ewriter.py +1 -4
- myokit/formats/latex/_exporter.py +4 -6
- myokit/formats/mathml/__init__.py +0 -3
- myokit/formats/mathml/_ewriter.py +2 -11
- myokit/formats/mathml/_parser.py +4 -6
- myokit/formats/matlab/__init__.py +0 -3
- myokit/formats/matlab/_ewriter.py +1 -4
- myokit/formats/matlab/_exporter.py +2 -5
- myokit/formats/matlab/template/main.m +3 -2
- myokit/formats/opencl/__init__.py +0 -3
- myokit/formats/opencl/_ewriter.py +2 -4
- myokit/formats/opencl/_exporter.py +2 -5
- myokit/formats/opencl/template/cable.c +10 -10
- myokit/formats/opencl/template/kernel.cl +1 -1
- myokit/formats/opencl/template/minilog.py +1 -1
- myokit/formats/python/__init__.py +0 -3
- myokit/formats/python/_ewriter.py +2 -5
- myokit/formats/python/_exporter.py +0 -3
- myokit/formats/python/template/sim.py +14 -14
- myokit/formats/sbml/__init__.py +0 -3
- myokit/formats/sbml/_api.py +50 -44
- myokit/formats/sbml/_importer.py +1 -4
- myokit/formats/sbml/_parser.py +2 -5
- myokit/formats/stan/__init__.py +0 -3
- myokit/formats/stan/_ewriter.py +2 -4
- myokit/formats/stan/_exporter.py +2 -5
- myokit/formats/stan/template/cell.stan +3 -3
- myokit/formats/sympy/__init__.py +0 -3
- myokit/formats/sympy/_ereader.py +1 -4
- myokit/formats/sympy/_ewriter.py +2 -5
- myokit/formats/wcp/__init__.py +0 -3
- myokit/formats/wcp/_wcp.py +2 -8
- myokit/formats/xml/__init__.py +0 -3
- myokit/formats/xml/_exporter.py +0 -3
- myokit/formats/xml/_split.py +0 -3
- myokit/gui/__init__.py +80 -246
- myokit/gui/datablock_viewer.py +103 -86
- myokit/gui/datalog_viewer.py +214 -66
- myokit/gui/explorer.py +15 -21
- myokit/gui/ide.py +171 -144
- myokit/gui/progress.py +9 -9
- myokit/gui/source.py +406 -375
- myokit/gui/vargrapher.py +2 -12
- myokit/lib/deps.py +12 -13
- myokit/lib/guess.py +3 -4
- myokit/lib/hh.py +20 -18
- myokit/lib/markov.py +21 -20
- myokit/lib/multi.py +1 -3
- myokit/lib/plots.py +20 -9
- myokit/pacing.py +0 -3
- myokit/pype.py +7 -18
- myokit/tests/__init__.py +3 -6
- myokit/tests/ansic_event_based_pacing.py +1 -4
- myokit/tests/ansic_fixed_form_pacing.py +3 -6
- myokit/tests/data/beeler-1977-model-compare-b.mmt +2 -2
- myokit/tests/data/clancy-1999-fitting.mmt +1 -0
- myokit/tests/test_aux.py +13 -28
- myokit/tests/test_cellml_v1_api.py +4 -19
- myokit/tests/test_cellml_v1_parser.py +0 -15
- myokit/tests/test_cellml_v1_writer.py +0 -9
- myokit/tests/test_cellml_v2_api.py +4 -19
- myokit/tests/test_cellml_v2_parser.py +0 -15
- myokit/tests/test_cellml_v2_writer.py +0 -9
- myokit/tests/test_cmodel.py +16 -22
- myokit/tests/test_compiler_detection.py +1 -11
- myokit/tests/test_component.py +108 -56
- myokit/tests/test_config.py +34 -67
- myokit/tests/test_datablock.py +1 -9
- myokit/tests/test_datalog.py +19 -24
- myokit/tests/test_dependency_checking.py +8 -23
- myokit/tests/test_expressions.py +0 -9
- myokit/tests/test_float.py +1 -5
- myokit/tests/test_formats.py +0 -9
- myokit/tests/test_formats_axon.py +1 -9
- myokit/tests/test_formats_cellml.py +0 -15
- myokit/tests/test_formats_channelml.py +0 -15
- myokit/tests/test_formats_easyml.py +0 -14
- myokit/tests/test_formats_exporters.py +1 -16
- myokit/tests/test_formats_expression_writers.py +1 -17
- myokit/tests/test_formats_html.py +0 -3
- myokit/tests/test_formats_importers.py +1 -16
- myokit/tests/test_formats_mathml_content.py +0 -9
- myokit/tests/test_formats_mathml_presentation.py +0 -9
- myokit/tests/test_formats_opencl.py +0 -10
- myokit/tests/test_formats_sbml.py +0 -15
- myokit/tests/test_formats_sympy.py +0 -9
- myokit/tests/test_formats_wcp.py +1 -3
- myokit/tests/test_io.py +27 -27
- myokit/tests/test_jacobian_calculator.py +6 -14
- myokit/tests/test_jacobian_tracer.py +0 -9
- myokit/tests/test_lib_deps.py +0 -9
- myokit/tests/test_lib_guess.py +0 -9
- myokit/tests/test_lib_hh.py +18 -12
- myokit/tests/test_lib_markov.py +21 -13
- myokit/tests/test_lib_multi.py +0 -9
- myokit/tests/test_lib_plots.py +13 -8
- myokit/tests/test_meta.py +0 -3
- myokit/tests/test_model.py +390 -96
- myokit/tests/test_model_building.py +44 -96
- myokit/tests/test_opencl_info.py +5 -14
- myokit/tests/test_pacing_factory.py +0 -3
- myokit/tests/test_pacing_system_c.py +1 -23
- myokit/tests/test_pacing_system_py.py +0 -9
- myokit/tests/test_parsing.py +139 -56
- myokit/tests/test_progress_reporters.py +0 -3
- myokit/tests/test_protocol.py +0 -9
- myokit/tests/test_protocol_floating_point.py +1 -10
- myokit/tests/test_protocol_time_series.py +82 -0
- myokit/tests/test_pype.py +0 -9
- myokit/tests/test_quantity.py +0 -9
- myokit/tests/test_rhs_benchmarker.py +1 -9
- myokit/tests/test_sbml_api.py +27 -42
- myokit/tests/test_sbml_parser.py +4 -19
- myokit/tests/test_simulation_1d.py +45 -25
- myokit/tests/test_simulation_cvodes.py +321 -55
- myokit/tests/test_simulation_cvodes_from_disk.py +0 -3
- myokit/tests/test_simulation_fiber_tissue.py +39 -12
- myokit/tests/test_simulation_log_interval.py +1 -431
- myokit/tests/test_simulation_opencl.py +69 -48
- myokit/tests/test_simulation_opencl_log_interval.py +1 -3
- myokit/tests/test_simulation_opencl_vs_cvode.py +1 -10
- myokit/tests/test_simulation_opencl_vs_sim1d.py +1 -10
- myokit/tests/test_system_info.py +1 -11
- myokit/tests/test_tools.py +0 -9
- myokit/tests/test_unit.py +1 -10
- myokit/tests/test_user_functions.py +0 -10
- myokit/tests/test_variable.py +231 -27
- myokit/tools.py +5 -21
- myokit/units.py +5 -3
- {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/METADATA +12 -15
- myokit-1.35.0.dist-info/RECORD +391 -0
- {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/WHEEL +1 -1
- {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/entry_points.txt +0 -1
- myokit/_exec_new.py +0 -15
- myokit/_exec_old.py +0 -15
- myokit/_sim/cvodesim.c +0 -1551
- myokit/_sim/cvodesim.py +0 -674
- myokit/_sim/icsim.cpp +0 -563
- myokit/_sim/icsim.py +0 -363
- myokit/_sim/psim.cpp +0 -656
- myokit/_sim/psim.py +0 -493
- myokit/lib/common.py +0 -1094
- myokit/tests/test_lib_common.py +0 -130
- myokit/tests/test_simulation_cvode.py +0 -612
- myokit/tests/test_simulation_ic.py +0 -108
- myokit/tests/test_simulation_p.py +0 -223
- myokit-1.33.9.dist-info/RECORD +0 -403
- /myokit/formats/opencl/template/{test → test.sh} +0 -0
- {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/LICENSE.txt +0 -0
- {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/top_level.txt +0 -0
myokit/formats/axon/_abf.py
CHANGED
|
@@ -139,23 +139,22 @@
|
|
|
139
139
|
# Information - but no direct code - from the matlab script get_abf_header.m
|
|
140
140
|
# was also used: http://neurodata.hg.sourceforge.net/hgweb/neurodata/neurodata/
|
|
141
141
|
#------------------------------------------------------------------------------
|
|
142
|
-
from __future__ import absolute_import, division
|
|
143
|
-
from __future__ import print_function, unicode_literals
|
|
144
|
-
|
|
145
|
-
from collections import OrderedDict
|
|
146
|
-
import numpy as np
|
|
147
|
-
import traceback
|
|
148
142
|
import datetime
|
|
149
143
|
import logging
|
|
150
|
-
import struct
|
|
151
144
|
import os
|
|
145
|
+
import struct
|
|
146
|
+
import traceback
|
|
147
|
+
|
|
148
|
+
import numpy as np
|
|
149
|
+
|
|
150
|
+
from collections import OrderedDict
|
|
152
151
|
|
|
153
152
|
|
|
154
153
|
# Encoding for text parts of files
|
|
155
154
|
_ENC = 'latin-1'
|
|
156
155
|
|
|
157
156
|
|
|
158
|
-
class AbfFile
|
|
157
|
+
class AbfFile:
|
|
159
158
|
"""
|
|
160
159
|
Represents a read-only Axon Binary Format file (``.abf``), stored at the
|
|
161
160
|
location pointed to by ``filepath``.
|
|
@@ -199,7 +198,6 @@ class AbfFile(object):
|
|
|
199
198
|
"""
|
|
200
199
|
def __init__(self, filepath, is_protocol_file=None):
|
|
201
200
|
# The path to the file and its basename
|
|
202
|
-
# Ensure it's a `str` for Python2/3 compatibility
|
|
203
201
|
filepath = str(filepath)
|
|
204
202
|
self._filepath = os.path.abspath(filepath)
|
|
205
203
|
self._filename = os.path.basename(filepath)
|
|
@@ -254,7 +252,6 @@ class AbfFile(object):
|
|
|
254
252
|
# cases that trigger this error they should be resolved. At the
|
|
255
253
|
# same time, if it happens to a user we want it to "sort-of work"
|
|
256
254
|
# (an experimental rather than a production setting)
|
|
257
|
-
logging.basicConfig()
|
|
258
255
|
log = logging.getLogger(__name__)
|
|
259
256
|
log.warning('Unable to read protocol from ' + self._filepath)
|
|
260
257
|
log.warning(traceback.format_exc())
|
|
@@ -703,7 +700,6 @@ class AbfFile(object):
|
|
|
703
700
|
"""
|
|
704
701
|
Read and unpack a file section using the given format ``form``.
|
|
705
702
|
"""
|
|
706
|
-
# Form must be a str (so bytes on Python 2)
|
|
707
703
|
form = str(form)
|
|
708
704
|
if offset is not None:
|
|
709
705
|
f.seek(offset)
|
|
@@ -1065,7 +1061,6 @@ class AbfFile(object):
|
|
|
1065
1061
|
|
|
1066
1062
|
else: # pragma: no cover
|
|
1067
1063
|
|
|
1068
|
-
logging.basicConfig()
|
|
1069
1064
|
log = logging.getLogger(__name__)
|
|
1070
1065
|
log.warning(
|
|
1071
1066
|
'Unsupported epoch type: ' + epoch_types(kind))
|
|
@@ -1308,14 +1303,14 @@ class AbfFile(object):
|
|
|
1308
1303
|
self._adc_offsets.append(s)
|
|
1309
1304
|
|
|
1310
1305
|
|
|
1311
|
-
class Sweep
|
|
1306
|
+
class Sweep:
|
|
1312
1307
|
"""
|
|
1313
1308
|
Represents a single sweep (also called an 'episode')
|
|
1314
1309
|
|
|
1315
1310
|
A sweep is represented as a fixed-size list of channels.
|
|
1316
1311
|
"""
|
|
1317
1312
|
def __init__(self, n):
|
|
1318
|
-
super(
|
|
1313
|
+
super().__init__()
|
|
1319
1314
|
n = int(n)
|
|
1320
1315
|
if n < 0: # pragma: no cover
|
|
1321
1316
|
raise ValueError('Number channels cannot be negative.')
|
|
@@ -1338,14 +1333,14 @@ class Sweep(object):
|
|
|
1338
1333
|
self._channels[key] = value
|
|
1339
1334
|
|
|
1340
1335
|
|
|
1341
|
-
class Channel
|
|
1336
|
+
class Channel:
|
|
1342
1337
|
"""
|
|
1343
1338
|
Represents an analog signal for a single channel.
|
|
1344
1339
|
|
|
1345
1340
|
To obtain this channel's formatted data, use times() and trace()
|
|
1346
1341
|
"""
|
|
1347
1342
|
def __init__(self, parent_file):
|
|
1348
|
-
super(
|
|
1343
|
+
super().__init__()
|
|
1349
1344
|
self._parent_file = parent_file # The abf file this channel is from
|
|
1350
1345
|
self._type = TYPE_UNKNOWN # Type of recording
|
|
1351
1346
|
|
|
@@ -1388,7 +1383,7 @@ class Channel(object):
|
|
|
1388
1383
|
def number(self):
|
|
1389
1384
|
"""
|
|
1390
1385
|
Returns the channel index used by pClamp. Note that this does not
|
|
1391
|
-
necessarily equal its index in the
|
|
1386
|
+
necessarily equal its index in the Python sweep data!
|
|
1392
1387
|
"""
|
|
1393
1388
|
return self._numb
|
|
1394
1389
|
|
myokit/formats/axon/_atf.py
CHANGED
|
@@ -4,20 +4,19 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
|
-
from collections import OrderedDict
|
|
11
|
-
import numpy as np
|
|
12
7
|
import os
|
|
13
8
|
import re
|
|
14
9
|
|
|
10
|
+
import numpy as np
|
|
11
|
+
|
|
12
|
+
from collections import OrderedDict
|
|
13
|
+
|
|
15
14
|
|
|
16
15
|
# Format used for any text
|
|
17
16
|
_ENC = 'ascii'
|
|
18
17
|
|
|
19
18
|
|
|
20
|
-
class AtfFile
|
|
19
|
+
class AtfFile:
|
|
21
20
|
"""
|
|
22
21
|
Represents an Axon Text File (ATF) stored on disk.
|
|
23
22
|
|
myokit/formats/axon/_importer.py
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from ._exporter import CellMLExporter, CellML1Exporter, CellML2Exporter
|
|
11
8
|
from ._ewriter import CellMLExpressionWriter
|
|
12
9
|
from ._importer import CellMLImporter, CellMLImporterError # noqa
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from lxml import etree
|
|
11
8
|
|
|
12
9
|
import myokit
|
|
@@ -24,8 +21,8 @@ class CellMLExpressionWriter(MathMLExpressionWriter):
|
|
|
24
21
|
unit names with :meth:`set_unit_function()`.
|
|
25
22
|
"""
|
|
26
23
|
def __init__(self, version='1.0'):
|
|
27
|
-
super(
|
|
28
|
-
super(
|
|
24
|
+
super().__init__()
|
|
25
|
+
super().set_mode(presentation=False)
|
|
29
26
|
|
|
30
27
|
# Units lookup method
|
|
31
28
|
self._funits = None
|
|
@@ -54,7 +51,7 @@ class CellMLExpressionWriter(MathMLExpressionWriter):
|
|
|
54
51
|
self._funits = f
|
|
55
52
|
|
|
56
53
|
def _ex_number(self, e, t):
|
|
57
|
-
x = super(
|
|
54
|
+
x = super()._ex_number(e, t)
|
|
58
55
|
unit = e.unit()
|
|
59
56
|
if self._funits is not None and unit is not None:
|
|
60
57
|
units = self._funits(e.unit())
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
import myokit
|
|
11
8
|
import myokit.lib.guess
|
|
12
9
|
|
|
@@ -18,7 +15,7 @@ class CellMLExporter(myokit.formats.Exporter):
|
|
|
18
15
|
This:class:`Exporter <myokit.formats.Exporter>` creates a CellML model.
|
|
19
16
|
"""
|
|
20
17
|
def __init__(self):
|
|
21
|
-
super(
|
|
18
|
+
super().__init__()
|
|
22
19
|
|
|
23
20
|
def model(self, path, model, protocol=None, version='1.0'):
|
|
24
21
|
"""
|
|
@@ -69,7 +66,7 @@ class CellML1Exporter(CellMLExporter):
|
|
|
69
66
|
This:class:`Exporter <myokit.formats.Exporter>` creates a CellML 1.0 model.
|
|
70
67
|
"""
|
|
71
68
|
def model(self, path, model, protocol=None):
|
|
72
|
-
super(
|
|
69
|
+
super().model(path, model, protocol, '1.0')
|
|
73
70
|
|
|
74
71
|
|
|
75
72
|
class CellML2Exporter(CellMLExporter):
|
|
@@ -77,5 +74,5 @@ class CellML2Exporter(CellMLExporter):
|
|
|
77
74
|
This:class:`Exporter <myokit.formats.Exporter>` creates a CellML 2.0 model.
|
|
78
75
|
"""
|
|
79
76
|
def model(self, path, model, protocol=None):
|
|
80
|
-
super(
|
|
77
|
+
super().model(path, model, protocol, '2.0')
|
|
81
78
|
|
|
@@ -5,9 +5,6 @@
|
|
|
5
5
|
# This file is part of Myokit.
|
|
6
6
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
7
7
|
#
|
|
8
|
-
from __future__ import absolute_import, division
|
|
9
|
-
from __future__ import print_function, unicode_literals
|
|
10
|
-
|
|
11
8
|
from lxml import etree
|
|
12
9
|
|
|
13
10
|
import myokit
|
|
@@ -28,7 +25,7 @@ class CellMLImporter(myokit.formats.Importer):
|
|
|
28
25
|
from CellML.
|
|
29
26
|
"""
|
|
30
27
|
def __init__(self, verbose=False):
|
|
31
|
-
super(
|
|
28
|
+
super().__init__()
|
|
32
29
|
|
|
33
30
|
def model(self, path):
|
|
34
31
|
"""
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from ._api import ( # noqa
|
|
11
8
|
AnnotatableElement,
|
|
12
9
|
CellMLError,
|
|
@@ -22,7 +19,6 @@ from ._api import ( # noqa
|
|
|
22
19
|
is_valid_identifier,
|
|
23
20
|
)
|
|
24
21
|
|
|
25
|
-
|
|
26
22
|
from ._parser import ( # noqa
|
|
27
23
|
parse_file,
|
|
28
24
|
parse_string,
|
myokit/formats/cellml/v1/_api.py
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
import collections
|
|
11
8
|
import re
|
|
12
9
|
import warnings
|
|
@@ -116,7 +113,7 @@ def create_unit_name(unit):
|
|
|
116
113
|
return name
|
|
117
114
|
|
|
118
115
|
|
|
119
|
-
class AnnotatableElement
|
|
116
|
+
class AnnotatableElement:
|
|
120
117
|
"""
|
|
121
118
|
Represents a CellML 1.0 or 1.1 element that can have a cmeta:id.
|
|
122
119
|
|
|
@@ -187,7 +184,7 @@ class UnsupportedBaseUnitsError(UnitsError):
|
|
|
187
184
|
"""
|
|
188
185
|
def __init__(self, units):
|
|
189
186
|
self.units = units
|
|
190
|
-
super(
|
|
187
|
+
super().__init__(
|
|
191
188
|
'Unsupported base units "' + units + '".')
|
|
192
189
|
|
|
193
190
|
|
|
@@ -196,7 +193,7 @@ class UnsupportedUnitOffsetError(UnitsError):
|
|
|
196
193
|
Raised when units with non-zero offsets are used.
|
|
197
194
|
"""
|
|
198
195
|
def __init__(self):
|
|
199
|
-
super(
|
|
196
|
+
super().__init__(
|
|
200
197
|
'Units with non-zero offsets are not supported.')
|
|
201
198
|
|
|
202
199
|
|
|
@@ -206,7 +203,7 @@ class Component(AnnotatableElement):
|
|
|
206
203
|
:meth:`Model.add_component()`.
|
|
207
204
|
"""
|
|
208
205
|
def __init__(self, model, name):
|
|
209
|
-
super(
|
|
206
|
+
super().__init__(model)
|
|
210
207
|
|
|
211
208
|
# Store model
|
|
212
209
|
self._model = model
|
|
@@ -474,7 +471,7 @@ class Model(AnnotatableElement):
|
|
|
474
471
|
|
|
475
472
|
"""
|
|
476
473
|
def __init__(self, name, version='1.0'):
|
|
477
|
-
super(
|
|
474
|
+
super().__init__(self)
|
|
478
475
|
|
|
479
476
|
# Check and store name
|
|
480
477
|
if not is_valid_identifier(name):
|
|
@@ -898,7 +895,7 @@ class Model(AnnotatableElement):
|
|
|
898
895
|
# Promote states and set rhs and initial value
|
|
899
896
|
elif variable.is_state():
|
|
900
897
|
v.set_is_state(True)
|
|
901
|
-
v.set_initial_value(variable.
|
|
898
|
+
v.set_initial_value(variable.initial_value(True))
|
|
902
899
|
v.set_rhs(rhs)
|
|
903
900
|
|
|
904
901
|
# Store literals (single number) in initial value
|
|
@@ -1165,7 +1162,7 @@ class Model(AnnotatableElement):
|
|
|
1165
1162
|
return self._version
|
|
1166
1163
|
|
|
1167
1164
|
|
|
1168
|
-
class Units
|
|
1165
|
+
class Units:
|
|
1169
1166
|
"""
|
|
1170
1167
|
Represents a CellML units definition, should not be created directly but
|
|
1171
1168
|
only via :meth:`Model.add_units()` or :meth:`Component.add_units()`.
|
|
@@ -1470,7 +1467,7 @@ class Variable(AnnotatableElement):
|
|
|
1470
1467
|
"""
|
|
1471
1468
|
def __init__(self, component, name, units, public_interface='none',
|
|
1472
1469
|
private_interface='none'):
|
|
1473
|
-
super(
|
|
1470
|
+
super().__init__(component.model())
|
|
1474
1471
|
|
|
1475
1472
|
# Store component
|
|
1476
1473
|
self._component = component
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
import collections
|
|
11
8
|
import warnings
|
|
12
9
|
|
|
@@ -60,10 +57,10 @@ class CellMLParsingError(myokit.ImportError):
|
|
|
60
57
|
message = 'Error on line ' + line + '. ' + message
|
|
61
58
|
except AttributeError:
|
|
62
59
|
pass
|
|
63
|
-
super(
|
|
60
|
+
super().__init__(message)
|
|
64
61
|
|
|
65
62
|
|
|
66
|
-
class CellMLParser
|
|
63
|
+
class CellMLParser:
|
|
67
64
|
"""
|
|
68
65
|
Parses CellML 1.0 and 1.1 documents, and performs (partial) validation of a
|
|
69
66
|
CellML document.
|
|
@@ -4,21 +4,12 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from lxml import etree
|
|
8
|
+
from urllib.parse import quote
|
|
11
9
|
|
|
12
10
|
import myokit
|
|
13
11
|
import myokit.formats.cellml as cellml
|
|
14
12
|
|
|
15
|
-
# Quoting URI strings in Python2 and Python3
|
|
16
|
-
try:
|
|
17
|
-
from urllib.parse import quote
|
|
18
|
-
except ImportError: # pragma: no python 3 cover
|
|
19
|
-
# Python 2
|
|
20
|
-
from urllib import quote
|
|
21
|
-
|
|
22
13
|
|
|
23
14
|
# Left-over from old exporter. Not sure if this had any function.
|
|
24
15
|
# Add name in 'tmp-documentation' format
|
|
@@ -45,7 +36,7 @@ def write_string(model):
|
|
|
45
36
|
return CellMLWriter().write_string(model)
|
|
46
37
|
|
|
47
38
|
|
|
48
|
-
class CellMLWriter
|
|
39
|
+
class CellMLWriter:
|
|
49
40
|
"""
|
|
50
41
|
Writes CellML 1.0 or 1.1 documents.
|
|
51
42
|
"""
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from ._api import ( # noqa
|
|
11
8
|
AnnotatableElement,
|
|
12
9
|
CellMLError,
|
myokit/formats/cellml/v2/_api.py
CHANGED
|
@@ -4,21 +4,12 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
import collections
|
|
11
8
|
import re
|
|
12
9
|
import warnings
|
|
13
10
|
|
|
14
11
|
import myokit
|
|
15
12
|
|
|
16
|
-
# Strings in Python2 and Python3
|
|
17
|
-
try:
|
|
18
|
-
basestring
|
|
19
|
-
except NameError: # pragma: no cover
|
|
20
|
-
basestring = str
|
|
21
|
-
|
|
22
13
|
|
|
23
14
|
# Data types
|
|
24
15
|
_cellml_identifier = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$')
|
|
@@ -142,7 +133,7 @@ def create_unit_name(unit):
|
|
|
142
133
|
return name
|
|
143
134
|
|
|
144
135
|
|
|
145
|
-
class AnnotatableElement
|
|
136
|
+
class AnnotatableElement:
|
|
146
137
|
"""
|
|
147
138
|
Represents a CellML 2.0 element that can be annotated (using a public dict
|
|
148
139
|
``meta`` that stores key:value pairs).
|
|
@@ -167,7 +158,7 @@ class Component(AnnotatableElement):
|
|
|
167
158
|
:meth:`Model.add_component()`.
|
|
168
159
|
"""
|
|
169
160
|
def __init__(self, model, name):
|
|
170
|
-
super(
|
|
161
|
+
super().__init__()
|
|
171
162
|
|
|
172
163
|
# Store model
|
|
173
164
|
self._model = model
|
|
@@ -323,7 +314,7 @@ class Model(AnnotatableElement):
|
|
|
323
314
|
|
|
324
315
|
"""
|
|
325
316
|
def __init__(self, name, version='2.0'):
|
|
326
|
-
super(
|
|
317
|
+
super().__init__()
|
|
327
318
|
|
|
328
319
|
# Check and store name
|
|
329
320
|
if not is_identifier(name):
|
|
@@ -802,7 +793,7 @@ class Model(AnnotatableElement):
|
|
|
802
793
|
|
|
803
794
|
# Promote states and set rhs and initial value
|
|
804
795
|
elif variable.is_state():
|
|
805
|
-
v.set_initial_value(variable.
|
|
796
|
+
v.set_initial_value(variable.initial_value(True))
|
|
806
797
|
v.set_equation(myokit.Equation(lhs, rhs))
|
|
807
798
|
|
|
808
799
|
# Store literals (single number) in initial value
|
|
@@ -1068,7 +1059,7 @@ class Model(AnnotatableElement):
|
|
|
1068
1059
|
return self._version
|
|
1069
1060
|
|
|
1070
1061
|
|
|
1071
|
-
class Units
|
|
1062
|
+
class Units:
|
|
1072
1063
|
"""
|
|
1073
1064
|
Represents a CellML units definition; should not be created directly but
|
|
1074
1065
|
only via :meth:`Model.add_units()` or :meth:`Component.add_units()`.
|
|
@@ -1359,7 +1350,7 @@ class Variable(AnnotatableElement):
|
|
|
1359
1350
|
|
|
1360
1351
|
"""
|
|
1361
1352
|
def __init__(self, component, name, units, interface='none'):
|
|
1362
|
-
super(
|
|
1353
|
+
super().__init__()
|
|
1363
1354
|
|
|
1364
1355
|
# Store model and component
|
|
1365
1356
|
self._model = component.model()
|
|
@@ -1615,7 +1606,7 @@ class Variable(AnnotatableElement):
|
|
|
1615
1606
|
if value is not None:
|
|
1616
1607
|
|
|
1617
1608
|
# Check value is a real number string
|
|
1618
|
-
if isinstance(value,
|
|
1609
|
+
if isinstance(value, str):
|
|
1619
1610
|
if is_real_number_string(value):
|
|
1620
1611
|
value = float(value)
|
|
1621
1612
|
else:
|
|
@@ -1642,7 +1633,7 @@ class Variable(AnnotatableElement):
|
|
|
1642
1633
|
return self._units
|
|
1643
1634
|
|
|
1644
1635
|
|
|
1645
|
-
class ConnectedVariableSet
|
|
1636
|
+
class ConnectedVariableSet:
|
|
1646
1637
|
"""
|
|
1647
1638
|
Represents a set of connected variables.
|
|
1648
1639
|
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
import warnings
|
|
11
8
|
|
|
12
9
|
from lxml import etree
|
|
@@ -59,10 +56,10 @@ class CellMLParsingError(myokit.ImportError):
|
|
|
59
56
|
message = 'Error on line ' + line + '. ' + message
|
|
60
57
|
except AttributeError:
|
|
61
58
|
pass
|
|
62
|
-
super(
|
|
59
|
+
super().__init__(message)
|
|
63
60
|
|
|
64
61
|
|
|
65
|
-
class CellMLParser
|
|
62
|
+
class CellMLParser:
|
|
66
63
|
"""
|
|
67
64
|
Parses CellML 2.0 documents, and performs (partial) validation.
|
|
68
65
|
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from lxml import etree
|
|
11
8
|
|
|
12
9
|
import myokit
|
|
@@ -27,7 +24,7 @@ def write_string(model):
|
|
|
27
24
|
return CellMLWriter().write_string(model)
|
|
28
25
|
|
|
29
26
|
|
|
30
|
-
class CellMLWriter
|
|
27
|
+
class CellMLWriter:
|
|
31
28
|
"""
|
|
32
29
|
Writes CellML 2.0 documents.
|
|
33
30
|
"""
|
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from ._importer import ChannelMLImporter, ChannelMLError # noqa
|
|
11
8
|
|
|
12
9
|
|
|
@@ -4,23 +4,13 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
7
|
+
import io
|
|
10
8
|
import os
|
|
11
9
|
import textwrap
|
|
10
|
+
import warnings
|
|
12
11
|
import xml.dom
|
|
13
12
|
import xml.dom.minidom
|
|
14
13
|
|
|
15
|
-
import warnings
|
|
16
|
-
|
|
17
|
-
try:
|
|
18
|
-
# Python 2
|
|
19
|
-
from cStringIO import StringIO
|
|
20
|
-
except ImportError:
|
|
21
|
-
# Python3
|
|
22
|
-
from io import StringIO
|
|
23
|
-
|
|
24
14
|
import myokit
|
|
25
15
|
from myokit import formats
|
|
26
16
|
from myokit import Name, Number, Minus, Multiply, Divide, Power
|
|
@@ -71,7 +61,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
71
61
|
from the ChannelML format.
|
|
72
62
|
"""
|
|
73
63
|
def __init__(self, verbose=False):
|
|
74
|
-
super(
|
|
64
|
+
super().__init__()
|
|
75
65
|
self.generated_name_index = 0
|
|
76
66
|
|
|
77
67
|
def component(self, path, model):
|
|
@@ -147,7 +137,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
147
137
|
' supported.')
|
|
148
138
|
|
|
149
139
|
# Add channel component
|
|
150
|
-
name = self.
|
|
140
|
+
name = self._sanitize_name(root.getAttribute('name'))
|
|
151
141
|
if name in model:
|
|
152
142
|
name_root = name
|
|
153
143
|
i = 2
|
|
@@ -200,7 +190,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
200
190
|
# Add gates
|
|
201
191
|
gvars = []
|
|
202
192
|
for gate in cvr.getElementsByTagName('gate'):
|
|
203
|
-
gname = self.
|
|
193
|
+
gname = self._sanitize_name(gate.getAttribute('name'))
|
|
204
194
|
gvar = component.add_variable(gname)
|
|
205
195
|
gvar.promote(0)
|
|
206
196
|
cstate = gate.getElementsByTagName('closed_state')
|
|
@@ -242,7 +232,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
242
232
|
+ gname + '>')
|
|
243
233
|
|
|
244
234
|
# Add closed-to-open transition
|
|
245
|
-
tname = self.
|
|
235
|
+
tname = self._sanitize_name(tco.getAttribute('name'))
|
|
246
236
|
tcovar = gvar.add_variable(tname)
|
|
247
237
|
expr = str(tco.getAttribute('expr'))
|
|
248
238
|
try:
|
|
@@ -255,7 +245,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
255
245
|
tcovar.meta['expression'] = str(expr)
|
|
256
246
|
|
|
257
247
|
# Add open-to-closed transition
|
|
258
|
-
tname = self.
|
|
248
|
+
tname = self._sanitize_name(toc.getAttribute('name'))
|
|
259
249
|
tocvar = gvar.add_variable(tname)
|
|
260
250
|
expr = str(toc.getAttribute('expr'))
|
|
261
251
|
try:
|
|
@@ -284,7 +274,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
284
274
|
tc = tc[0]
|
|
285
275
|
|
|
286
276
|
# Add steady-state variable
|
|
287
|
-
ssname = self.
|
|
277
|
+
ssname = self._sanitize_name(ss.getAttribute('name'))
|
|
288
278
|
ssvar = gvar.add_variable(ssname)
|
|
289
279
|
expr = str(ss.getAttribute('expr'))
|
|
290
280
|
try:
|
|
@@ -296,7 +286,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
296
286
|
ssvar.meta['expression'] = str(expr)
|
|
297
287
|
|
|
298
288
|
# Add time course variable
|
|
299
|
-
tcname = self.
|
|
289
|
+
tcname = self._sanitize_name(tc.getAttribute('name'))
|
|
300
290
|
tcvar = gvar.add_variable(tcname)
|
|
301
291
|
expr = str(tc.getAttribute('expr'))
|
|
302
292
|
try:
|
|
@@ -373,7 +363,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
373
363
|
if not root.hasAttribute('xmlns:meta'):
|
|
374
364
|
return None
|
|
375
365
|
ns = root.getAttribute('xmlns:meta')
|
|
376
|
-
b = StringIO()
|
|
366
|
+
b = io.StringIO()
|
|
377
367
|
|
|
378
368
|
def scan(parent):
|
|
379
369
|
kid = dom_child(parent)
|
|
@@ -412,7 +402,7 @@ class ChannelMLImporter(formats.Importer):
|
|
|
412
402
|
return textwrap.fill(
|
|
413
403
|
str('\n'.join(text(node))), 70, replace_whitespace=False)
|
|
414
404
|
|
|
415
|
-
def
|
|
405
|
+
def _sanitize_name(self, name):
|
|
416
406
|
"""
|
|
417
407
|
Tests if a name is a valid myokit name. Adapts it if it isn't.
|
|
418
408
|
"""
|
myokit/formats/cpp/__init__.py
CHANGED
|
@@ -4,10 +4,8 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
import myokit.formats.ansic
|
|
8
|
+
|
|
11
9
|
from ._ewriter import CppExpressionWriter
|
|
12
10
|
|
|
13
11
|
|
myokit/formats/cpp/_ewriter.py
CHANGED
|
@@ -4,9 +4,6 @@
|
|
|
4
4
|
# This file is part of Myokit.
|
|
5
5
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
6
|
#
|
|
7
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
7
|
from myokit.formats.ansic import AnsiCExpressionWriter
|
|
11
8
|
|
|
12
9
|
|