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/cuda/__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 CudaKernelExporter, CudaKernelRLExporter
|
|
11
8
|
from ._ewriter import CudaExpressionWriter
|
|
12
9
|
from myokit.formats import ansic
|
myokit/formats/cuda/_ewriter.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
|
|
8
|
+
|
|
11
9
|
from myokit.formats.python import PythonExpressionWriter
|
|
12
10
|
|
|
13
11
|
|
|
@@ -17,7 +15,7 @@ class CudaExpressionWriter(PythonExpressionWriter):
|
|
|
17
15
|
Myokit :class:`expressions <myokit.Expression>` to their CUDA equivalents.
|
|
18
16
|
"""
|
|
19
17
|
def __init__(self, precision=myokit.SINGLE_PRECISION):
|
|
20
|
-
super(
|
|
18
|
+
super().__init__()
|
|
21
19
|
self._function_prefix = ''
|
|
22
20
|
self._sp = (precision == myokit.SINGLE_PRECISION)
|
|
23
21
|
|
myokit/formats/cuda/_exporter.py
CHANGED
|
@@ -66,13 +66,16 @@ model.reserve_unique_names(
|
|
|
66
66
|
)
|
|
67
67
|
model.create_unique_names()
|
|
68
68
|
|
|
69
|
+
# Get initial values (before time binding is removed and model becomes invalid)
|
|
70
|
+
initial_values = model.initial_values(True)
|
|
71
|
+
|
|
69
72
|
# Process bindings, remove unsupported bindings, get map of bound variables to
|
|
70
73
|
# internal names
|
|
71
|
-
bound_variables =
|
|
74
|
+
bound_variables = myokit._prepare_bindings(model, {
|
|
72
75
|
#'time' : 'time',
|
|
73
76
|
#'pace' : 'pace',
|
|
74
77
|
'diffusion_current' : 'I_diff',
|
|
75
|
-
|
|
78
|
+
})
|
|
76
79
|
|
|
77
80
|
# Get equations
|
|
78
81
|
equations = model.solvable_order()
|
|
@@ -190,7 +193,7 @@ for group in equations.values():
|
|
|
190
193
|
print('')
|
|
191
194
|
print('/* Aliases of state variables. */')
|
|
192
195
|
for var in model.states():
|
|
193
|
-
print('#define ' + var.uname() + ' state[' + str(var.
|
|
196
|
+
print('#define ' + var.uname() + ' state[' + str(var.index()) + ']')
|
|
194
197
|
|
|
195
198
|
?>
|
|
196
199
|
|
|
@@ -295,10 +298,10 @@ int get_default_initial_state(Real *state)
|
|
|
295
298
|
if (state == 0) return(-1);
|
|
296
299
|
|
|
297
300
|
<?
|
|
298
|
-
for var in model.states():
|
|
301
|
+
for var, val in zip(model.states(), initial_values):
|
|
299
302
|
if 'desc' in var.meta:
|
|
300
303
|
print(tab + '// ' + var.meta['desc'])
|
|
301
|
-
print(tab + v(var) + ' = ' + myokit.float.str(
|
|
304
|
+
print(tab + v(var) + ' = ' + myokit.float.str(val) + ';')
|
|
302
305
|
?>
|
|
303
306
|
|
|
304
307
|
return(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 EasyMLExporter
|
|
11
8
|
from ._ewriter import EasyMLExpressionWriter
|
|
12
9
|
|
|
@@ -4,12 +4,10 @@
|
|
|
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
|
import myokit
|
|
10
|
+
|
|
13
11
|
from myokit.formats.python import PythonExpressionWriter
|
|
14
12
|
|
|
15
13
|
|
|
@@ -19,7 +17,7 @@ class EasyMLExpressionWriter(PythonExpressionWriter):
|
|
|
19
17
|
equations for variables in EasyML syntax.
|
|
20
18
|
"""
|
|
21
19
|
def __init__(self):
|
|
22
|
-
super(
|
|
20
|
+
super().__init__()
|
|
23
21
|
self._function_prefix = ''
|
|
24
22
|
|
|
25
23
|
#def _ex_name(self, e):
|
|
@@ -39,7 +37,7 @@ class EasyMLExpressionWriter(PythonExpressionWriter):
|
|
|
39
37
|
if isinstance(e[1], myokit.Exp) and isinstance(e[0], myokit.Number):
|
|
40
38
|
if e[0].eval() == 1:
|
|
41
39
|
return '-expm1(' + self.ex(e[1][0]) + ')'
|
|
42
|
-
return super(
|
|
40
|
+
return super()._ex_minus(e)
|
|
43
41
|
|
|
44
42
|
#def _ex_multiply(self, e):
|
|
45
43
|
#def _ex_divide(self, e):
|
|
@@ -58,23 +56,23 @@ class EasyMLExpressionWriter(PythonExpressionWriter):
|
|
|
58
56
|
|
|
59
57
|
def _ex_sin(self, e):
|
|
60
58
|
warnings.warn('Potentially unsupported function: sin()')
|
|
61
|
-
return super(
|
|
59
|
+
return super()._ex_sin(e)
|
|
62
60
|
|
|
63
61
|
#def _ex_cos(self, e):
|
|
64
62
|
|
|
65
63
|
def _ex_tan(self, e):
|
|
66
64
|
warnings.warn('Potentially unsupported function: tan()')
|
|
67
|
-
return super(
|
|
65
|
+
return super()._ex_tan(e)
|
|
68
66
|
|
|
69
67
|
def _ex_asin(self, e):
|
|
70
68
|
warnings.warn('Potentially unsupported function: asin()')
|
|
71
|
-
return super(
|
|
69
|
+
return super()._ex_asin(e)
|
|
72
70
|
|
|
73
71
|
#def _ex_acos(self, e):
|
|
74
72
|
|
|
75
73
|
def _ex_atan(self, e):
|
|
76
74
|
warnings.warn('Potentially unsupported function: atan()')
|
|
77
|
-
return super(
|
|
75
|
+
return super()._ex_atan(e)
|
|
78
76
|
|
|
79
77
|
#def _ex_exp(self, e):
|
|
80
78
|
|
|
@@ -87,11 +85,11 @@ class EasyMLExpressionWriter(PythonExpressionWriter):
|
|
|
87
85
|
|
|
88
86
|
def _ex_floor(self, e):
|
|
89
87
|
warnings.warn('Potentially unsupported function: floor()')
|
|
90
|
-
return super(
|
|
88
|
+
return super()._ex_floor(e)
|
|
91
89
|
|
|
92
90
|
def _ex_ceil(self, e):
|
|
93
91
|
warnings.warn('Potentially unsupported function: ceil()')
|
|
94
|
-
return super(
|
|
92
|
+
return super()._ex_ceil(e)
|
|
95
93
|
|
|
96
94
|
def _ex_abs(self, e):
|
|
97
95
|
return self._ex_function(e, 'fabs')
|
|
@@ -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 os
|
|
12
9
|
import warnings
|
|
@@ -372,8 +369,8 @@ class EasyMLExporter(myokit.formats.Exporter):
|
|
|
372
369
|
|
|
373
370
|
# Write initial conditions
|
|
374
371
|
for v in model.states():
|
|
375
|
-
f.write(lhs(v) + '_init = '
|
|
376
|
-
+ eos)
|
|
372
|
+
f.write(lhs(v) + '_init = '
|
|
373
|
+
+ myokit.float.str(v.initial_value(True)) + eos)
|
|
377
374
|
f.write(eol)
|
|
378
375
|
|
|
379
376
|
# Write remaining variables
|
myokit/formats/html/__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 HTMLExporter
|
|
11
8
|
from ._flatten import html2ascii # noqa
|
|
12
9
|
|
myokit/formats/html/_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
|
from lxml import etree
|
|
11
8
|
|
|
12
9
|
import myokit
|
myokit/formats/html/_flatten.py
CHANGED
|
@@ -4,19 +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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
import html
|
|
8
|
+
import html.parser
|
|
10
9
|
import re
|
|
11
|
-
import sys
|
|
12
10
|
import textwrap
|
|
13
11
|
|
|
14
|
-
# HTML Parser in Python 2 and 3
|
|
15
|
-
try:
|
|
16
|
-
from HTMLParser import HTMLParser
|
|
17
|
-
except ImportError:
|
|
18
|
-
from html.parser import HTMLParser
|
|
19
|
-
|
|
20
12
|
|
|
21
13
|
def html2ascii(html, width=79, indent=' '):
|
|
22
14
|
"""
|
|
@@ -32,21 +24,13 @@ def html2ascii(html, width=79, indent=' '):
|
|
|
32
24
|
return f.get_text()
|
|
33
25
|
|
|
34
26
|
|
|
35
|
-
class Asciifier(HTMLParser):
|
|
27
|
+
class Asciifier(html.parser.HTMLParser):
|
|
36
28
|
INDENT = 1
|
|
37
29
|
DEDENT = -1
|
|
38
30
|
WHITE = [' ', '\t', '\f', '\r', '\n']
|
|
39
31
|
|
|
40
32
|
def __init__(self, line_width=79, indent=' '):
|
|
41
|
-
|
|
42
|
-
# HTMLParser requires old-school constructor
|
|
43
|
-
HTMLParser.__init__(self)
|
|
44
|
-
else: # pragma: no python 2 cover
|
|
45
|
-
super(Asciifier, self).__init__(convert_charrefs=False)
|
|
46
|
-
|
|
47
|
-
# Unescape method is deprecated
|
|
48
|
-
import html
|
|
49
|
-
self.unescape = html.unescape
|
|
33
|
+
super().__init__(convert_charrefs=False)
|
|
50
34
|
|
|
51
35
|
# In <head> yes/no
|
|
52
36
|
self.inhead = False
|
|
@@ -226,7 +210,7 @@ class Asciifier(HTMLParser):
|
|
|
226
210
|
return
|
|
227
211
|
|
|
228
212
|
# Convert html characters
|
|
229
|
-
data =
|
|
213
|
+
data = html.unescape('&' + name + ';')
|
|
230
214
|
|
|
231
215
|
# Convert to ascii and back to strip out non-ascii content
|
|
232
216
|
data = data.encode('ascii', 'ignore').decode('ascii')
|
myokit/formats/latex/__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 PdfExporter, PosterExporter
|
|
11
8
|
from ._ewriter import LatexExpressionWriter
|
|
12
9
|
|
myokit/formats/latex/_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
|
import myokit.formats
|
|
11
8
|
|
|
12
9
|
|
|
@@ -16,7 +13,7 @@ class LatexExpressionWriter(myokit.formats.ExpressionWriter):
|
|
|
16
13
|
Myokit :class:`expressions <myokit.Expression>` to their Tex equivalent.
|
|
17
14
|
"""
|
|
18
15
|
def __init__(self):
|
|
19
|
-
super(
|
|
16
|
+
super().__init__()
|
|
20
17
|
|
|
21
18
|
# Default time variable
|
|
22
19
|
self._time = None
|
|
@@ -4,12 +4,10 @@
|
|
|
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
|
|
10
|
+
|
|
13
11
|
from ._ewriter import LatexExpressionWriter
|
|
14
12
|
|
|
15
13
|
|
|
@@ -19,7 +17,7 @@ class PdfExporter(myokit.formats.Exporter):
|
|
|
19
17
|
a simple latex document.
|
|
20
18
|
"""
|
|
21
19
|
def __init__(self):
|
|
22
|
-
super(
|
|
20
|
+
super().__init__()
|
|
23
21
|
|
|
24
22
|
def _clean(self, text):
|
|
25
23
|
"""
|
|
@@ -76,7 +74,7 @@ class PdfExporter(myokit.formats.Exporter):
|
|
|
76
74
|
f.write('\\begin{dmath}\n')
|
|
77
75
|
f.write(e.ex(myokit.Name(v)))
|
|
78
76
|
f.write(' = ')
|
|
79
|
-
f.write(e.ex(
|
|
77
|
+
f.write(e.ex(v.initial_value()))
|
|
80
78
|
f.write('\\end{dmath}\n')
|
|
81
79
|
|
|
82
80
|
# Write each component
|
|
@@ -111,7 +109,7 @@ class PosterExporter(myokit.formats.Exporter):
|
|
|
111
109
|
beholders.
|
|
112
110
|
"""
|
|
113
111
|
def __init__(self):
|
|
114
|
-
super(
|
|
112
|
+
super().__init__()
|
|
115
113
|
|
|
116
114
|
def post_export_info(self):
|
|
117
115
|
return '\n'.join((
|
|
@@ -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 ._ewriter import MathMLExpressionWriter
|
|
11
8
|
from ._parser import ( # noqa
|
|
12
9
|
MathMLError,
|
|
@@ -4,19 +4,10 @@
|
|
|
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.formats
|
|
13
10
|
|
|
14
|
-
# Strings in Python 2 and 3
|
|
15
|
-
try:
|
|
16
|
-
basestring
|
|
17
|
-
except NameError: # pragma: no cover
|
|
18
|
-
basestring = str
|
|
19
|
-
|
|
20
11
|
|
|
21
12
|
class MathMLExpressionWriter(myokit.formats.ExpressionWriter):
|
|
22
13
|
"""
|
|
@@ -25,7 +16,7 @@ class MathMLExpressionWriter(myokit.formats.ExpressionWriter):
|
|
|
25
16
|
Presentation MathML.
|
|
26
17
|
"""
|
|
27
18
|
def __init__(self):
|
|
28
|
-
super(
|
|
19
|
+
super().__init__()
|
|
29
20
|
|
|
30
21
|
# Default mode
|
|
31
22
|
self._pres = False
|
|
@@ -33,7 +24,7 @@ class MathMLExpressionWriter(myokit.formats.ExpressionWriter):
|
|
|
33
24
|
# Default lhs conversion function
|
|
34
25
|
def flhs(lhs):
|
|
35
26
|
var = lhs.var()
|
|
36
|
-
if isinstance(var,
|
|
27
|
+
if isinstance(var, str):
|
|
37
28
|
# This can happen with time variable of derivative if the
|
|
38
29
|
# proper variable isn't set!
|
|
39
30
|
return var
|
myokit/formats/mathml/_parser.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
|
|
8
|
+
|
|
11
9
|
from myokit.formats.xml import split
|
|
12
10
|
|
|
13
11
|
|
|
@@ -63,10 +61,10 @@ class MathMLError(myokit.ImportError):
|
|
|
63
61
|
message = 'Error on line ' + line + '. ' + message
|
|
64
62
|
except AttributeError:
|
|
65
63
|
pass
|
|
66
|
-
super(
|
|
64
|
+
super().__init__(message)
|
|
67
65
|
|
|
68
66
|
|
|
69
|
-
class MathMLParser
|
|
67
|
+
class MathMLParser:
|
|
70
68
|
"""
|
|
71
69
|
Parses MathML expressions into :class:`myokit.Expression` objects.
|
|
72
70
|
|
|
@@ -84,7 +82,7 @@ class MathMLParser(object):
|
|
|
84
82
|
will be added to this set.
|
|
85
83
|
|
|
86
84
|
This is not a validating parser: if the MathML is invalid the method's
|
|
87
|
-
|
|
85
|
+
behavior is undefined.
|
|
88
86
|
|
|
89
87
|
The following MathML elements are recognised:
|
|
90
88
|
|
|
@@ -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 MatlabExporter
|
|
11
8
|
from ._ewriter import MatlabExpressionWriter
|
|
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
|
from myokit.formats.python import PythonExpressionWriter
|
|
11
8
|
|
|
12
9
|
|
|
@@ -16,7 +13,7 @@ class MatlabExpressionWriter(PythonExpressionWriter):
|
|
|
16
13
|
Myokit :class:`expressions <myokit.Expression>` to a Matlab syntax.
|
|
17
14
|
"""
|
|
18
15
|
def __init__(self):
|
|
19
|
-
super(
|
|
16
|
+
super().__init__()
|
|
20
17
|
self._function_prefix = ''
|
|
21
18
|
self._fcond = 'ifthenelse'
|
|
22
19
|
|
|
@@ -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
|
|
@@ -67,7 +64,7 @@ class MatlabExporter(myokit.formats.TemplatedRunnableExporter):
|
|
|
67
64
|
# Variable naming function
|
|
68
65
|
def v(var):
|
|
69
66
|
if isinstance(var, myokit.Derivative):
|
|
70
|
-
return 'ydot(' + str(1 + var.var().
|
|
67
|
+
return 'ydot(' + str(1 + var.var().index()) + ')'
|
|
71
68
|
if isinstance(var, myokit.Name):
|
|
72
69
|
var = var.var()
|
|
73
70
|
if var.is_constant():
|
|
@@ -81,7 +78,7 @@ class MatlabExporter(myokit.formats.TemplatedRunnableExporter):
|
|
|
81
78
|
ew.set_condition_function('ifthenelse')
|
|
82
79
|
|
|
83
80
|
# Process bound variables
|
|
84
|
-
bound_variables =
|
|
81
|
+
bound_variables = myokit._prepare_bindings(model, {
|
|
85
82
|
'time': 't',
|
|
86
83
|
'pace': 'pace',
|
|
87
84
|
})
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
# This file is part of Myokit.
|
|
6
6
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
7
7
|
#
|
|
8
|
+
import myokit
|
|
8
9
|
?>%
|
|
9
10
|
% Driver file for <?= model.name() ?>
|
|
10
11
|
%
|
|
@@ -15,8 +16,8 @@ clear all
|
|
|
15
16
|
|
|
16
17
|
% Initial values
|
|
17
18
|
<?
|
|
18
|
-
for
|
|
19
|
-
print(
|
|
19
|
+
for var, value in zip(model.states(), model.initial_values(True)):
|
|
20
|
+
print(v(var) + ' = ' + myokit.float.str(value) + ';')
|
|
20
21
|
?>
|
|
21
22
|
|
|
22
23
|
% Vector for initial values
|
|
@@ -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 OpenCLExporter, OpenCLRLExporter
|
|
11
8
|
from ._ewriter import OpenCLExpressionWriter
|
|
12
9
|
from myokit.formats import ansic
|
|
@@ -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
|
|
8
|
+
|
|
11
9
|
from myokit.formats.python import PythonExpressionWriter
|
|
12
10
|
|
|
13
11
|
|
|
@@ -17,7 +15,7 @@ class OpenCLExpressionWriter(PythonExpressionWriter):
|
|
|
17
15
|
Myokit :class:`expressions <myokit.Expression>` to OpenCL syntax.
|
|
18
16
|
"""
|
|
19
17
|
def __init__(self, precision=myokit.SINGLE_PRECISION, native_math=True):
|
|
20
|
-
super(
|
|
18
|
+
super().__init__()
|
|
21
19
|
self._function_prefix = ''
|
|
22
20
|
self._sp = (precision == myokit.SINGLE_PRECISION)
|
|
23
21
|
self._nm = bool(native_math)
|
|
@@ -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
|
|
@@ -44,7 +41,7 @@ class OpenCLExporter(myokit.formats.TemplatedRunnableExporter):
|
|
|
44
41
|
'kernel.cl': 'kernel.cl',
|
|
45
42
|
'plot.py': 'plot.py',
|
|
46
43
|
'minilog.py': 'minilog.py',
|
|
47
|
-
'test': 'test',
|
|
44
|
+
'test.sh': 'test.sh',
|
|
48
45
|
}
|
|
49
46
|
|
|
50
47
|
def _vars(self, model, protocol):
|
|
@@ -80,7 +77,7 @@ class OpenCLExporter(myokit.formats.TemplatedRunnableExporter):
|
|
|
80
77
|
|
|
81
78
|
# Process bindings, remove unsupported bindings, get map of bound
|
|
82
79
|
# variables to internal names.
|
|
83
|
-
bound_variables =
|
|
80
|
+
bound_variables = myokit._prepare_bindings(model, {
|
|
84
81
|
'time': 'time',
|
|
85
82
|
'pace': 'pace',
|
|
86
83
|
'diffusion_current': 'idiff',
|
|
@@ -192,7 +192,7 @@ void set_initial_values(int n_cells, Real* s)
|
|
|
192
192
|
for(i=0; i<n_cells; i++) {
|
|
193
193
|
<?
|
|
194
194
|
for v in model.states():
|
|
195
|
-
print(tab*2 + '*s = ' + myokit.float.str(v.
|
|
195
|
+
print(tab*2 + '*s = ' + myokit.float.str(v.initial_value(True)) + '; s++; // ' + str(v.qname()))
|
|
196
196
|
?>
|
|
197
197
|
}
|
|
198
198
|
}
|
|
@@ -234,14 +234,14 @@ int run(const int n_cells, const Real time_start, const Real time_end, const Rea
|
|
|
234
234
|
cl_device_id device_id = get_device_id();
|
|
235
235
|
char buffer[65536];
|
|
236
236
|
ocl(clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(buffer), buffer, NULL));
|
|
237
|
-
printf("Using device: %s\n", buffer);
|
|
237
|
+
// printf("Using device: %s\n", buffer);
|
|
238
238
|
|
|
239
239
|
/* Create a context and command queue */
|
|
240
240
|
cl_int err;
|
|
241
241
|
context = clCreateContext(NULL, 1, &device_id, NULL, NULL, &err);
|
|
242
242
|
ocl_check("clCreateContext", err);
|
|
243
243
|
command_queue = clCreateCommandQueue(context, device_id, 0, &err);
|
|
244
|
-
printf("Created context and command queue.\n");
|
|
244
|
+
// printf("Created context and command queue.\n");
|
|
245
245
|
|
|
246
246
|
/* Create state vector */
|
|
247
247
|
int dsize_state = n_cells * n_state * sizeof(Real);
|
|
@@ -258,12 +258,12 @@ int run(const int n_cells, const Real time_start, const Real time_end, const Rea
|
|
|
258
258
|
ocl_check("clCreateBuffer mbuf_state", err);
|
|
259
259
|
mbuf_idiff = clCreateBuffer(context, CL_MEM_READ_ONLY, dsize_idiff, NULL, &err);
|
|
260
260
|
ocl_check("clCreateBuffer mbuf_idiff", err);
|
|
261
|
-
printf("Created buffers.\n");
|
|
261
|
+
// printf("Created buffers.\n");
|
|
262
262
|
|
|
263
263
|
/* Copy data into buffers */
|
|
264
264
|
ocl(clEnqueueWriteBuffer(command_queue, mbuf_state, CL_TRUE, 0, dsize_state, state, 0, NULL, NULL));
|
|
265
265
|
ocl(clEnqueueWriteBuffer(command_queue, mbuf_idiff, CL_TRUE, 0, dsize_idiff, idiff, 0, NULL, NULL));
|
|
266
|
-
printf("Set initial state.\n");
|
|
266
|
+
// printf("Set initial state.\n");
|
|
267
267
|
|
|
268
268
|
/* Load and compile the kernel program(s) */
|
|
269
269
|
char* source = read_kernel("kernel.cl");
|
|
@@ -285,14 +285,14 @@ int run(const int n_cells, const Real time_start, const Real time_end, const Rea
|
|
|
285
285
|
abort();
|
|
286
286
|
}
|
|
287
287
|
ocl_check("clBuildProgram", err);
|
|
288
|
-
printf("Program created and built.\n");
|
|
288
|
+
// printf("Program created and built.\n");
|
|
289
289
|
|
|
290
290
|
/* Create the kernels */
|
|
291
291
|
kernel_cell = clCreateKernel(program, "cell_step", &err);
|
|
292
292
|
ocl_check("clCreateKernel", err);
|
|
293
293
|
kernel_diff = clCreateKernel(program, "diff_step", &err);
|
|
294
294
|
ocl_check("clCreateKernel", err);
|
|
295
|
-
printf("Kernels created.\n");
|
|
295
|
+
// printf("Kernels created.\n");
|
|
296
296
|
|
|
297
297
|
/* Pass arguments into kernels */
|
|
298
298
|
ocl(clSetKernelArg(kernel_cell, 0, sizeof(n_cells), &n_cells));
|
|
@@ -304,7 +304,7 @@ int run(const int n_cells, const Real time_start, const Real time_end, const Rea
|
|
|
304
304
|
ocl(clSetKernelArg(kernel_diff, 1, sizeof(g), &g));
|
|
305
305
|
ocl(clSetKernelArg(kernel_diff, 2, sizeof(mbuf_state), &mbuf_state));
|
|
306
306
|
ocl(clSetKernelArg(kernel_diff, 3, sizeof(mbuf_idiff), &mbuf_idiff));
|
|
307
|
-
printf("Arguments passed into kernels.\n");
|
|
307
|
+
// printf("Arguments passed into kernels.\n");
|
|
308
308
|
|
|
309
309
|
/* Add log header */
|
|
310
310
|
printf("engine.time");
|
|
@@ -342,7 +342,7 @@ for v in model.states():
|
|
|
342
342
|
|
|
343
343
|
done:
|
|
344
344
|
/* Tidy up */
|
|
345
|
-
printf("Tidying up.\n");
|
|
345
|
+
// printf("Tidying up.\n");
|
|
346
346
|
|
|
347
347
|
ocl(clFlush(command_queue));
|
|
348
348
|
ocl(clFinish(command_queue));
|
|
@@ -356,7 +356,7 @@ done:
|
|
|
356
356
|
free(state);
|
|
357
357
|
free(idiff);
|
|
358
358
|
|
|
359
|
-
printf("Done.\n");
|
|
359
|
+
// printf("Done.\n");
|
|
360
360
|
}
|
|
361
361
|
|
|
362
362
|
int main()
|
|
@@ -140,7 +140,7 @@ for group in equations.values():
|
|
|
140
140
|
print('')
|
|
141
141
|
print('/* Aliases of state variables. */')
|
|
142
142
|
for var in model.states():
|
|
143
|
-
print('#define ' + var.uname() + ' state[offset + ' + str(var.
|
|
143
|
+
print('#define ' + var.uname() + ' state[offset + ' + str(var.index()) + ']')
|
|
144
144
|
|
|
145
145
|
print('')
|
|
146
146
|
for comp, ilist in comp_in.items():
|