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
|
@@ -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 PythonExporter
|
|
11
8
|
from ._ewriter import PythonExpressionWriter, NumPyExpressionWriter
|
|
12
9
|
|
|
@@ -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.formats
|
|
11
8
|
|
|
12
9
|
|
|
@@ -17,7 +14,7 @@ class PythonExpressionWriter(myokit.formats.ExpressionWriter):
|
|
|
17
14
|
equivalent.
|
|
18
15
|
"""
|
|
19
16
|
def __init__(self):
|
|
20
|
-
super(
|
|
17
|
+
super().__init__()
|
|
21
18
|
|
|
22
19
|
self._flhs = None
|
|
23
20
|
self.set_lhs_function(lambda v: str(v))
|
|
@@ -192,7 +189,7 @@ class NumPyExpressionWriter(PythonExpressionWriter):
|
|
|
192
189
|
intended for use in NumPy arrays.
|
|
193
190
|
"""
|
|
194
191
|
def __init__(self):
|
|
195
|
-
super(
|
|
192
|
+
super().__init__()
|
|
196
193
|
self._function_prefix = 'numpy.'
|
|
197
194
|
#def _ex_name(self, e):
|
|
198
195
|
#def _ex_derivative(self, e):
|
|
@@ -45,7 +45,7 @@ w.set_lhs_function(v)
|
|
|
45
45
|
e = w.eq
|
|
46
46
|
|
|
47
47
|
# Process bindings
|
|
48
|
-
bound_variables =
|
|
48
|
+
bound_variables = myokit._prepare_bindings(model, {
|
|
49
49
|
'time' : 'engine.time',
|
|
50
50
|
'pace' : 'engine.pace',
|
|
51
51
|
})
|
|
@@ -73,7 +73,7 @@ for comp in components:
|
|
|
73
73
|
w.set_lhs_function(lambda x: v(x, comp))
|
|
74
74
|
|
|
75
75
|
?>
|
|
76
|
-
class <?= names[1]
|
|
76
|
+
class <?= names[1] ?>:
|
|
77
77
|
def __init__(self):
|
|
78
78
|
<?
|
|
79
79
|
for var in comp.variables(deep=True):
|
|
@@ -96,9 +96,9 @@ class <?= names[1] ?>(object):
|
|
|
96
96
|
Resets the state variables to their initial values
|
|
97
97
|
"""
|
|
98
98
|
<?
|
|
99
|
-
for
|
|
100
|
-
if
|
|
101
|
-
print(tab2 +
|
|
99
|
+
for var, value in zip(model.states(), model.initial_values(True)):
|
|
100
|
+
if var.parent() == comp:
|
|
101
|
+
print(tab2 + v(var, comp) + ' = ' + myokit.float.str(value))
|
|
102
102
|
?> def update(self):
|
|
103
103
|
"""
|
|
104
104
|
Re-calculates all values for the current time and state
|
|
@@ -118,7 +118,7 @@ class <?= names[1] ?>(object):
|
|
|
118
118
|
#
|
|
119
119
|
# Engine component
|
|
120
120
|
#
|
|
121
|
-
class Engine
|
|
121
|
+
class Engine:
|
|
122
122
|
"""
|
|
123
123
|
Calculates the derivatives in the current state
|
|
124
124
|
"""
|
|
@@ -213,10 +213,10 @@ def test_step():
|
|
|
213
213
|
#
|
|
214
214
|
# Pacing
|
|
215
215
|
#
|
|
216
|
-
class Protocol
|
|
216
|
+
class Protocol:
|
|
217
217
|
""" Holds an ordered set of ProtocolEvent objects """
|
|
218
218
|
def __init__(self):
|
|
219
|
-
super(
|
|
219
|
+
super().__init__()
|
|
220
220
|
self.head = None
|
|
221
221
|
def add(self, e):
|
|
222
222
|
""" Schedules an event """
|
|
@@ -238,9 +238,11 @@ class Protocol(object):
|
|
|
238
238
|
if self.head is not None:
|
|
239
239
|
self.head = self.head.next
|
|
240
240
|
return e
|
|
241
|
-
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
class ProtocolEvent:
|
|
242
244
|
def __init__(self, level, start, duration, period=0, multiplier=0):
|
|
243
|
-
super(
|
|
245
|
+
super().__init__()
|
|
244
246
|
self.level = float(level)
|
|
245
247
|
self.start = float(start)
|
|
246
248
|
self.duration = float(duration)
|
|
@@ -256,6 +258,7 @@ class ProtocolEvent(object):
|
|
|
256
258
|
raise Exception('Non-periodic event cannot occur more than once')
|
|
257
259
|
self.next = None
|
|
258
260
|
|
|
261
|
+
|
|
259
262
|
def pacing_protocol():
|
|
260
263
|
pacing = Protocol()
|
|
261
264
|
<?
|
|
@@ -377,10 +380,7 @@ if __name__ == '__main__':
|
|
|
377
380
|
except ArithmeticError as e:
|
|
378
381
|
print('Arithmetic error occurred')
|
|
379
382
|
y = 'Continue with smaller stepsize? (y/n): '
|
|
380
|
-
|
|
381
|
-
y = raw_input(y) # Python 2
|
|
382
|
-
except NameError:
|
|
383
|
-
y = input(y) # Python 3
|
|
383
|
+
y = input(y)
|
|
384
384
|
if y.lower()[0:1] == 'y':
|
|
385
385
|
small /= 2
|
|
386
386
|
large /= 2
|
myokit/formats/sbml/__init__.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 ._api import ( # noqa
|
|
11
8
|
Compartment,
|
|
12
9
|
CSymbolVariable,
|
myokit/formats/sbml/_api.py
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
#
|
|
2
|
+
# SBML API
|
|
3
|
+
#
|
|
4
|
+
# This file is part of Myokit.
|
|
5
|
+
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
6
|
+
#
|
|
1
7
|
import collections
|
|
2
8
|
import warnings
|
|
3
9
|
import re
|
|
@@ -16,7 +22,7 @@ class SBMLError(Exception):
|
|
|
16
22
|
"""Raised if something goes wrong when working with an SBML model."""
|
|
17
23
|
|
|
18
24
|
|
|
19
|
-
class Quantity
|
|
25
|
+
class Quantity:
|
|
20
26
|
"""
|
|
21
27
|
Base class for anything that has a numerical value in an SBML model, and
|
|
22
28
|
can be set by rules, reactions, or initial assignments.
|
|
@@ -52,8 +58,8 @@ class Quantity(object):
|
|
|
52
58
|
"""
|
|
53
59
|
if not isinstance(value, myokit.Expression):
|
|
54
60
|
raise SBMLError(
|
|
55
|
-
'<' + str(value) + '> needs to be an instance of
|
|
56
|
-
'myokit.Expression.')
|
|
61
|
+
'<' + str(value) + '> needs to be an instance of'
|
|
62
|
+
' myokit.Expression.')
|
|
57
63
|
|
|
58
64
|
self._initial_value = value
|
|
59
65
|
|
|
@@ -75,8 +81,8 @@ class Quantity(object):
|
|
|
75
81
|
"""
|
|
76
82
|
if not isinstance(value, myokit.Expression):
|
|
77
83
|
raise SBMLError(
|
|
78
|
-
'<' + str(value) + '> needs to be an instance of
|
|
79
|
-
'myokit.Expression.')
|
|
84
|
+
'<' + str(value) + '> needs to be an instance of'
|
|
85
|
+
' myokit.Expression.')
|
|
80
86
|
|
|
81
87
|
self._value = value
|
|
82
88
|
self._is_rate = bool(is_rate)
|
|
@@ -89,7 +95,7 @@ class Quantity(object):
|
|
|
89
95
|
return self._value
|
|
90
96
|
|
|
91
97
|
|
|
92
|
-
class CSymbolVariable
|
|
98
|
+
class CSymbolVariable:
|
|
93
99
|
"""
|
|
94
100
|
Represents a CSymbol that can appear in SBML expressions, but which has a
|
|
95
101
|
predetermind value and/or meaning, e.g. "time".
|
|
@@ -122,12 +128,12 @@ class Compartment(Quantity):
|
|
|
122
128
|
|
|
123
129
|
"""
|
|
124
130
|
def __init__(self, model, sid):
|
|
125
|
-
super(
|
|
131
|
+
super().__init__()
|
|
126
132
|
|
|
127
133
|
if not isinstance(model, Model):
|
|
128
134
|
raise SBMLError(
|
|
129
|
-
'<' + str(model) + '> needs to be an instance of
|
|
130
|
-
'myokit.formats.sbml.Model.')
|
|
135
|
+
'<' + str(model) + '> needs to be an instance of'
|
|
136
|
+
' myokit.formats.sbml.Model.')
|
|
131
137
|
|
|
132
138
|
self._model = model
|
|
133
139
|
self._sid = str(sid)
|
|
@@ -185,7 +191,7 @@ class Compartment(Quantity):
|
|
|
185
191
|
return '<Compartment ' + self._sid + '>'
|
|
186
192
|
|
|
187
193
|
|
|
188
|
-
class Model
|
|
194
|
+
class Model:
|
|
189
195
|
"""
|
|
190
196
|
Represents a model in SBML.
|
|
191
197
|
|
|
@@ -280,7 +286,7 @@ class Model(object):
|
|
|
280
286
|
if not isinstance(compartment, Compartment):
|
|
281
287
|
raise SBMLError(
|
|
282
288
|
'<' + compartment + '> needs to be instance of'
|
|
283
|
-
'myokit.formats.sbml.Compartment')
|
|
289
|
+
' myokit.formats.sbml.Compartment')
|
|
284
290
|
|
|
285
291
|
sid = str(sid) if sid else sid
|
|
286
292
|
self._register_sid(sid)
|
|
@@ -427,7 +433,7 @@ class Model(object):
|
|
|
427
433
|
if not isinstance(factor, Parameter):
|
|
428
434
|
raise SBMLError(
|
|
429
435
|
'<' + str(factor) + '> needs to be instance of'
|
|
430
|
-
'myokit.formats.sbml.Parameter.')
|
|
436
|
+
' myokit.formats.sbml.Parameter.')
|
|
431
437
|
|
|
432
438
|
self._conversion_factor = factor
|
|
433
439
|
|
|
@@ -581,12 +587,12 @@ class Parameter(Quantity):
|
|
|
581
587
|
|
|
582
588
|
"""
|
|
583
589
|
def __init__(self, model, sid):
|
|
584
|
-
super(
|
|
590
|
+
super().__init__()
|
|
585
591
|
|
|
586
592
|
if not isinstance(model, Model):
|
|
587
593
|
raise SBMLError(
|
|
588
|
-
'<' + str(model) + '> needs to be an instance of
|
|
589
|
-
'myokit.formats.sbml.Model.')
|
|
594
|
+
'<' + str(model) + '> needs to be an instance of'
|
|
595
|
+
' myokit.formats.sbml.Model.')
|
|
590
596
|
|
|
591
597
|
self._model = model
|
|
592
598
|
self._sid = str(sid)
|
|
@@ -612,7 +618,7 @@ class Parameter(Quantity):
|
|
|
612
618
|
return self._units
|
|
613
619
|
|
|
614
620
|
|
|
615
|
-
class Reaction
|
|
621
|
+
class Reaction:
|
|
616
622
|
"""
|
|
617
623
|
Represents an SBML reaction; to create a reaction use
|
|
618
624
|
:meth:`Model.add_reaction()`.
|
|
@@ -629,8 +635,8 @@ class Reaction(object):
|
|
|
629
635
|
|
|
630
636
|
if not isinstance(model, Model):
|
|
631
637
|
raise SBMLError(
|
|
632
|
-
'<' + str(model) + '> needs to be an instance of
|
|
633
|
-
'myokit.formats.sbml.Model.')
|
|
638
|
+
'<' + str(model) + '> needs to be an instance of'
|
|
639
|
+
' myokit.formats.sbml.Model.')
|
|
634
640
|
|
|
635
641
|
self._model = model
|
|
636
642
|
self._sid = str(sid)
|
|
@@ -650,8 +656,8 @@ class Reaction(object):
|
|
|
650
656
|
"""Adds a modifier to this reaction and returns the created object."""
|
|
651
657
|
if not isinstance(species, Species):
|
|
652
658
|
raise SBMLError(
|
|
653
|
-
'<' + str(species) + '> needs to be an instance of
|
|
654
|
-
'myokit.formats.sbml.Species')
|
|
659
|
+
'<' + str(species) + '> needs to be an instance of'
|
|
660
|
+
' myokit.formats.sbml.Species')
|
|
655
661
|
|
|
656
662
|
sid = str(sid) if sid else sid
|
|
657
663
|
if sid is not None:
|
|
@@ -668,8 +674,8 @@ class Reaction(object):
|
|
|
668
674
|
"""
|
|
669
675
|
if not isinstance(species, Species):
|
|
670
676
|
raise SBMLError(
|
|
671
|
-
'<' + str(species) + '> needs to be an instance of
|
|
672
|
-
'myokit.formats.sbml.Species')
|
|
677
|
+
'<' + str(species) + '> needs to be an instance of'
|
|
678
|
+
' myokit.formats.sbml.Species')
|
|
673
679
|
|
|
674
680
|
sid = str(sid) if sid else sid
|
|
675
681
|
if sid is not None:
|
|
@@ -685,8 +691,8 @@ class Reaction(object):
|
|
|
685
691
|
"""Adds a reactant to this reaction and returns the created object."""
|
|
686
692
|
if not isinstance(species, Species):
|
|
687
693
|
raise SBMLError(
|
|
688
|
-
'<' + str(species) + '> needs to be an instance of
|
|
689
|
-
'myokit.formats.sbml.Species')
|
|
694
|
+
'<' + str(species) + '> needs to be an instance of'
|
|
695
|
+
' myokit.formats.sbml.Species')
|
|
690
696
|
|
|
691
697
|
sid = str(sid) if sid else sid
|
|
692
698
|
if sid is not None:
|
|
@@ -731,8 +737,8 @@ class Reaction(object):
|
|
|
731
737
|
"""
|
|
732
738
|
if not isinstance(expression, myokit.Expression):
|
|
733
739
|
raise SBMLError(
|
|
734
|
-
'<' + str(expression) + '> needs to be an instance of
|
|
735
|
-
'myokit.Expression.')
|
|
740
|
+
'<' + str(expression) + '> needs to be an instance of'
|
|
741
|
+
' myokit.Expression.')
|
|
736
742
|
|
|
737
743
|
self._kinetic_law = expression
|
|
738
744
|
|
|
@@ -772,12 +778,12 @@ class Species(Quantity):
|
|
|
772
778
|
|
|
773
779
|
"""
|
|
774
780
|
def __init__(self, compartment, sid, is_amount, is_constant, is_boundary):
|
|
775
|
-
super(
|
|
781
|
+
super().__init__()
|
|
776
782
|
|
|
777
783
|
if not isinstance(compartment, Compartment):
|
|
778
784
|
raise SBMLError(
|
|
779
785
|
'<' + compartment + '> needs to be instance of'
|
|
780
|
-
'myokit.formats.sbml.Compartment')
|
|
786
|
+
' myokit.formats.sbml.Compartment')
|
|
781
787
|
if not isinstance(is_amount, bool):
|
|
782
788
|
raise SBMLError(
|
|
783
789
|
'Is_amount <' + str(is_amount) + '> needs to be a boolean.')
|
|
@@ -853,7 +859,7 @@ class Species(Quantity):
|
|
|
853
859
|
if not isinstance(factor, Parameter):
|
|
854
860
|
raise SBMLError(
|
|
855
861
|
'<' + str(factor) + '> needs to be instance of'
|
|
856
|
-
'myokit.formats.sbml.Parameter.')
|
|
862
|
+
' myokit.formats.sbml.Parameter.')
|
|
857
863
|
|
|
858
864
|
self._conversion_factor = factor
|
|
859
865
|
|
|
@@ -867,8 +873,8 @@ class Species(Quantity):
|
|
|
867
873
|
"""
|
|
868
874
|
if not isinstance(value, myokit.Expression):
|
|
869
875
|
raise SBMLError(
|
|
870
|
-
'<' + str(value) + '> needs to be an instance of
|
|
871
|
-
'myokit.Expression.')
|
|
876
|
+
'<' + str(value) + '> needs to be an instance of'
|
|
877
|
+
' myokit.Expression.')
|
|
872
878
|
if (in_amount is not None) and (not isinstance(in_amount, bool)):
|
|
873
879
|
raise SBMLError(
|
|
874
880
|
'<in_amount> needs to be an instance of bool or None.')
|
|
@@ -914,12 +920,12 @@ class SpeciesReference(Quantity):
|
|
|
914
920
|
MODIFIER = 2
|
|
915
921
|
|
|
916
922
|
def __init__(self, species, sid=None):
|
|
917
|
-
super(
|
|
923
|
+
super().__init__()
|
|
918
924
|
|
|
919
925
|
if not isinstance(species, Species):
|
|
920
926
|
raise SBMLError(
|
|
921
927
|
'<' + species + '> needs to be instance of'
|
|
922
|
-
'myokit.formats.sbml.Species')
|
|
928
|
+
' myokit.formats.sbml.Species')
|
|
923
929
|
|
|
924
930
|
self._species = species
|
|
925
931
|
self._sid = str(sid) if sid else sid
|
|
@@ -936,16 +942,16 @@ class SpeciesReference(Quantity):
|
|
|
936
942
|
return '<SpeciesReference ' + self._sid + '>'
|
|
937
943
|
|
|
938
944
|
|
|
939
|
-
class ModifierSpeciesReference
|
|
945
|
+
class ModifierSpeciesReference:
|
|
940
946
|
"""Represents a reference to a modifier species in an SBML reaction."""
|
|
941
947
|
|
|
942
948
|
def __init__(self, species, sid=None):
|
|
943
|
-
super(
|
|
949
|
+
super().__init__()
|
|
944
950
|
|
|
945
951
|
if not isinstance(species, Species):
|
|
946
952
|
raise SBMLError(
|
|
947
953
|
'<' + species + '> needs to be instance of'
|
|
948
|
-
'myokit.formats.sbml.Species')
|
|
954
|
+
' myokit.formats.sbml.Species')
|
|
949
955
|
|
|
950
956
|
self._species = species
|
|
951
957
|
self._sid = str(sid) if sid else sid
|
|
@@ -971,7 +977,7 @@ def convert_name(name):
|
|
|
971
977
|
return name
|
|
972
978
|
|
|
973
979
|
|
|
974
|
-
class _MyokitConverter
|
|
980
|
+
class _MyokitConverter:
|
|
975
981
|
"""
|
|
976
982
|
Converts SBML Models to Myokit models.
|
|
977
983
|
"""
|
|
@@ -1058,7 +1064,7 @@ class _MyokitConverter(object):
|
|
|
1058
1064
|
|
|
1059
1065
|
@staticmethod
|
|
1060
1066
|
def add_global_component(
|
|
1061
|
-
myokit_model, component_references, name='
|
|
1067
|
+
myokit_model, component_references, name='global'):
|
|
1062
1068
|
"""
|
|
1063
1069
|
Creates a component used to store global parameters and the time
|
|
1064
1070
|
variable.
|
|
@@ -1298,7 +1304,7 @@ class _MyokitConverter(object):
|
|
|
1298
1304
|
'with an initial value. Default is set to 1.')
|
|
1299
1305
|
|
|
1300
1306
|
# Promote size to state variable
|
|
1301
|
-
var.promote(state_value
|
|
1307
|
+
var.promote(state_value)
|
|
1302
1308
|
|
|
1303
1309
|
# Set RHS
|
|
1304
1310
|
# (assignmentRule overwrites initialAssignment)
|
|
@@ -1383,7 +1389,7 @@ class _MyokitConverter(object):
|
|
|
1383
1389
|
'value. Default is set to 0.')
|
|
1384
1390
|
|
|
1385
1391
|
# Promote size to state variable
|
|
1386
|
-
var.promote(state_value
|
|
1392
|
+
var.promote(state_value)
|
|
1387
1393
|
var.set_rhs(myokit.Number(0))
|
|
1388
1394
|
|
|
1389
1395
|
if (not var.rhs().is_literal()) or var.rhs().eval():
|
|
@@ -1473,7 +1479,7 @@ class _MyokitConverter(object):
|
|
|
1473
1479
|
'value. Default is set to 0.')
|
|
1474
1480
|
|
|
1475
1481
|
# Promote size to state variable
|
|
1476
|
-
var.promote(state_value
|
|
1482
|
+
var.promote(state_value)
|
|
1477
1483
|
var.set_rhs(myokit.Number(0))
|
|
1478
1484
|
|
|
1479
1485
|
if (not var.rhs().is_literal()) or var.rhs().eval():
|
|
@@ -1546,7 +1552,7 @@ class _MyokitConverter(object):
|
|
|
1546
1552
|
'value. Default is set to 0.')
|
|
1547
1553
|
|
|
1548
1554
|
# Promote size to state variable
|
|
1549
|
-
var.promote(state_value
|
|
1555
|
+
var.promote(state_value)
|
|
1550
1556
|
|
|
1551
1557
|
# Set RHS (reactions are dealt with elsewhere)
|
|
1552
1558
|
expr = species.value()
|
|
@@ -1607,7 +1613,7 @@ class _MyokitConverter(object):
|
|
|
1607
1613
|
' initial value. Default is set to 1.')
|
|
1608
1614
|
|
|
1609
1615
|
# Promote size to state variable
|
|
1610
|
-
var.promote(state_value
|
|
1616
|
+
var.promote(state_value)
|
|
1611
1617
|
|
|
1612
1618
|
# Set RHS
|
|
1613
1619
|
# (assignmentRule overwrites initialAssignment)
|
|
@@ -1673,7 +1679,7 @@ class _MyokitConverter(object):
|
|
|
1673
1679
|
' 1.')
|
|
1674
1680
|
|
|
1675
1681
|
# Promote size to state variable
|
|
1676
|
-
var.promote(state_value
|
|
1682
|
+
var.promote(state_value)
|
|
1677
1683
|
|
|
1678
1684
|
# Set RHS
|
|
1679
1685
|
# (assignmentRule overwrites initialAssignment)
|
myokit/formats/sbml/_importer.py
CHANGED
|
@@ -7,9 +7,6 @@
|
|
|
7
7
|
# This file is part of Myokit.
|
|
8
8
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
9
9
|
#
|
|
10
|
-
from __future__ import absolute_import, division
|
|
11
|
-
from __future__ import print_function, unicode_literals
|
|
12
|
-
|
|
13
10
|
import myokit.formats
|
|
14
11
|
|
|
15
12
|
|
|
@@ -22,7 +19,7 @@ class SBMLImporter(myokit.formats.Importer):
|
|
|
22
19
|
:class:`myokit.formats.sbml.SBMLParser`.
|
|
23
20
|
"""
|
|
24
21
|
def __init__(self):
|
|
25
|
-
super(
|
|
22
|
+
super().__init__()
|
|
26
23
|
|
|
27
24
|
def supports_model(self):
|
|
28
25
|
"""Returns ``True``."""
|
myokit/formats/sbml/_parser.py
CHANGED
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
# This file is part of Myokit.
|
|
9
9
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
10
10
|
#
|
|
11
|
-
from __future__ import absolute_import, division
|
|
12
|
-
from __future__ import print_function, unicode_literals
|
|
13
|
-
|
|
14
11
|
import re
|
|
15
12
|
import warnings
|
|
16
13
|
|
|
@@ -76,10 +73,10 @@ class SBMLParsingError(myokit.ImportError):
|
|
|
76
73
|
message = 'Error on line ' + line + '. ' + message
|
|
77
74
|
except AttributeError: # pragma: no cover
|
|
78
75
|
pass
|
|
79
|
-
super(
|
|
76
|
+
super().__init__(message)
|
|
80
77
|
|
|
81
78
|
|
|
82
|
-
class SBMLParser
|
|
79
|
+
class SBMLParser:
|
|
83
80
|
"""
|
|
84
81
|
Parses SBML models, creating an SBML Model structure that can be converted
|
|
85
82
|
to a :class:`myokit.Model` object.
|
myokit/formats/stan/__init__.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 StanExporter
|
|
11
8
|
from ._ewriter import StanExpressionWriter
|
|
12
9
|
|
myokit/formats/stan/_ewriter.py
CHANGED
|
@@ -6,10 +6,8 @@
|
|
|
6
6
|
# This file is part of Myokit.
|
|
7
7
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
8
8
|
#
|
|
9
|
-
from __future__ import absolute_import, division
|
|
10
|
-
from __future__ import print_function, unicode_literals
|
|
11
|
-
|
|
12
9
|
import myokit
|
|
10
|
+
|
|
13
11
|
from myokit.formats.python import PythonExpressionWriter
|
|
14
12
|
|
|
15
13
|
|
|
@@ -19,7 +17,7 @@ class StanExpressionWriter(PythonExpressionWriter):
|
|
|
19
17
|
Myokit:class:`expressions <myokit.Expression>` to a Stan syntax.
|
|
20
18
|
"""
|
|
21
19
|
def __init__(self):
|
|
22
|
-
super(
|
|
20
|
+
super().__init__()
|
|
23
21
|
self._function_prefix = ''
|
|
24
22
|
|
|
25
23
|
self._fcond = None
|
myokit/formats/stan/_exporter.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 os
|
|
11
8
|
|
|
12
9
|
import myokit.formats
|
|
@@ -61,7 +58,7 @@ class StanExporter(myokit.formats.TemplatedRunnableExporter):
|
|
|
61
58
|
ion current).
|
|
62
59
|
|
|
63
60
|
"""
|
|
64
|
-
super(
|
|
61
|
+
super().runnable(
|
|
65
62
|
path, model, protocol, parameters, output)
|
|
66
63
|
|
|
67
64
|
def _vars(self, model, protocol, parameters, output):
|
|
@@ -109,7 +106,7 @@ class StanExporter(myokit.formats.TemplatedRunnableExporter):
|
|
|
109
106
|
ew.set_lhs_function(v)
|
|
110
107
|
|
|
111
108
|
# Process bound variables
|
|
112
|
-
bound_variables =
|
|
109
|
+
bound_variables = myokit._prepare_bindings(model, {
|
|
113
110
|
'time': 'time',
|
|
114
111
|
'pace': 'pace',
|
|
115
112
|
})
|
|
@@ -21,7 +21,7 @@ functions{
|
|
|
21
21
|
*
|
|
22
22
|
* @param x The value to search for.
|
|
23
23
|
* @param sorted A sorted (non-decreasing) vector of values to search in.
|
|
24
|
-
* @return The greatest array
|
|
24
|
+
* @return The greatest array index `i` such that `sorted[i] <= x`
|
|
25
25
|
*/
|
|
26
26
|
int find_interval_elem(real x, vector sorted) {
|
|
27
27
|
|
|
@@ -83,10 +83,10 @@ functions{
|
|
|
83
83
|
vector[n] times = to_vector(xr[1:n]);
|
|
84
84
|
vector[n] values = to_vector(xr[(n + 1):(2 * n)]);
|
|
85
85
|
|
|
86
|
-
// Find
|
|
86
|
+
// Find index for current time
|
|
87
87
|
int i = find_interval_elem(time, values);
|
|
88
88
|
|
|
89
|
-
// Return pacing
|
|
89
|
+
// Return pacing valueo
|
|
90
90
|
return (i == 0) ? values[1] : values[i];
|
|
91
91
|
}
|
|
92
92
|
|
myokit/formats/sympy/__init__.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 ._ereader import SymPyExpressionReader
|
|
11
8
|
from ._ewriter import SymPyExpressionWriter
|
|
12
9
|
|
myokit/formats/sympy/_ereader.py
CHANGED
|
@@ -4,14 +4,11 @@
|
|
|
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.formats
|
|
12
9
|
|
|
13
10
|
|
|
14
|
-
class SymPyExpressionReader
|
|
11
|
+
class SymPyExpressionReader:
|
|
15
12
|
"""
|
|
16
13
|
Converts Sympy expressions to Myokit expressions.
|
|
17
14
|
|
myokit/formats/sympy/_ewriter.py
CHANGED
|
@@ -4,16 +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
|
|
7
|
+
import myokit.formats
|
|
9
8
|
|
|
10
9
|
try:
|
|
11
10
|
import sympy as sp
|
|
12
11
|
except ImportError:
|
|
13
12
|
pass
|
|
14
13
|
|
|
15
|
-
import myokit.formats
|
|
16
|
-
|
|
17
14
|
|
|
18
15
|
class SymPyExpressionWriter(myokit.formats.ExpressionWriter):
|
|
19
16
|
"""
|
|
@@ -23,7 +20,7 @@ class SymPyExpressionWriter(myokit.formats.ExpressionWriter):
|
|
|
23
20
|
The returned type is a SymPy object, not a string!
|
|
24
21
|
"""
|
|
25
22
|
def __init__(self):
|
|
26
|
-
super(
|
|
23
|
+
super().__init__()
|
|
27
24
|
|
|
28
25
|
self._flhs = None
|
|
29
26
|
self.set_lhs_function(lambda lhs: str(lhs))
|
myokit/formats/wcp/__init__.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 ._wcp import WcpFile # noqa
|
|
11
8
|
# Importers
|
|
12
9
|
# Exporters
|