myokit 1.34.0__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 +5 -23
- myokit/__main__.py +70 -117
- myokit/_aux.py +5 -8
- myokit/_config.py +22 -31
- myokit/_datablock.py +26 -70
- myokit/_datalog.py +23 -53
- myokit/_err.py +13 -15
- myokit/_expressions.py +35 -55
- myokit/_io.py +5 -22
- myokit/_model_api.py +34 -47
- myokit/_myokit_version.py +1 -5
- myokit/_parsing.py +17 -25
- myokit/_progress.py +4 -7
- myokit/_protocol.py +6 -9
- myokit/_sim/__init__.py +7 -24
- myokit/_sim/cable.c +1 -3
- myokit/_sim/cable.py +3 -5
- myokit/_sim/cmodel.h +1 -3
- myokit/_sim/cmodel.py +1 -4
- myokit/_sim/compiler.py +1 -4
- myokit/_sim/cvodessim.c +1 -4
- myokit/_sim/cvodessim.py +1 -4
- myokit/_sim/fiber_tissue.c +2 -6
- myokit/_sim/fiber_tissue.py +3 -5
- myokit/_sim/jacobian.py +6 -7
- myokit/_sim/mcl.h +51 -53
- myokit/_sim/opencl.py +9 -22
- myokit/_sim/openclsim.c +2 -6
- myokit/_sim/openclsim.py +6 -6
- myokit/_sim/pacing.h +2 -6
- myokit/_sim/rhs.c +3 -10
- myokit/_sim/rhs.py +4 -13
- myokit/_sim/sundials.py +1 -4
- myokit/_system.py +10 -16
- myokit/_unit.py +3 -12
- 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 +0 -3
- myokit/formats/axon/__init__.py +1 -3
- myokit/formats/axon/_abf.py +12 -15
- 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 +7 -10
- 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 +7 -16
- 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 +4 -14
- 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/easyml/__init__.py +0 -3
- myokit/formats/easyml/_ewriter.py +9 -11
- myokit/formats/easyml/_exporter.py +0 -3
- 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 +3 -5
- myokit/formats/mathml/__init__.py +0 -3
- myokit/formats/mathml/_ewriter.py +2 -11
- myokit/formats/mathml/_parser.py +3 -5
- myokit/formats/matlab/__init__.py +0 -3
- myokit/formats/matlab/_ewriter.py +1 -4
- myokit/formats/matlab/_exporter.py +0 -3
- myokit/formats/opencl/__init__.py +0 -3
- myokit/formats/opencl/_ewriter.py +2 -4
- myokit/formats/opencl/_exporter.py +0 -3
- 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 +10 -10
- myokit/formats/sbml/__init__.py +0 -3
- myokit/formats/sbml/_api.py +17 -11
- 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 +1 -4
- 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 +1 -7
- 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 +75 -247
- myokit/gui/datablock_viewer.py +100 -83
- myokit/gui/datalog_viewer.py +32 -44
- myokit/gui/explorer.py +15 -21
- myokit/gui/ide.py +105 -125
- myokit/gui/progress.py +9 -9
- myokit/gui/source.py +405 -374
- myokit/gui/vargrapher.py +2 -12
- myokit/lib/deps.py +7 -8
- myokit/lib/guess.py +1 -2
- myokit/lib/hh.py +5 -7
- myokit/lib/markov.py +9 -11
- myokit/lib/multi.py +1 -3
- myokit/lib/plots.py +1 -3
- 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 +1 -4
- myokit/tests/test_aux.py +9 -23
- myokit/tests/test_cellml_v1_api.py +1 -16
- 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 +1 -16
- myokit/tests/test_cellml_v2_parser.py +0 -15
- myokit/tests/test_cellml_v2_writer.py +0 -9
- myokit/tests/test_cmodel.py +0 -9
- myokit/tests/test_compiler_detection.py +1 -11
- myokit/tests/test_component.py +0 -10
- myokit/tests/test_config.py +33 -66
- myokit/tests/test_datablock.py +1 -9
- myokit/tests/test_datalog.py +4 -21
- 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 +6 -14
- myokit/tests/test_jacobian_calculator.py +1 -9
- 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 +1 -9
- myokit/tests/test_lib_markov.py +1 -9
- myokit/tests/test_lib_multi.py +0 -9
- myokit/tests/test_lib_plots.py +0 -3
- myokit/tests/test_meta.py +0 -3
- myokit/tests/test_model.py +0 -10
- myokit/tests/test_model_building.py +2 -17
- myokit/tests/test_opencl_info.py +5 -14
- myokit/tests/test_pacing_factory.py +0 -3
- myokit/tests/test_pacing_system_c.py +0 -9
- myokit/tests/test_pacing_system_py.py +0 -9
- myokit/tests/test_parsing.py +5 -20
- myokit/tests/test_progress_reporters.py +0 -3
- myokit/tests/test_protocol.py +0 -9
- myokit/tests/test_protocol_floating_point.py +0 -9
- myokit/tests/test_protocol_time_series.py +0 -10
- 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 +0 -15
- myokit/tests/test_sbml_parser.py +0 -15
- myokit/tests/test_simulation_1d.py +1 -10
- myokit/tests/test_simulation_cvodes.py +8 -16
- myokit/tests/test_simulation_cvodes_from_disk.py +0 -3
- myokit/tests/test_simulation_fiber_tissue.py +1 -10
- myokit/tests/test_simulation_log_interval.py +0 -9
- myokit/tests/test_simulation_opencl.py +1 -10
- 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 +0 -9
- myokit/tests/test_user_functions.py +0 -10
- myokit/tests/test_variable.py +0 -10
- myokit/tools.py +5 -21
- myokit/units.py +0 -3
- {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/METADATA +7 -7
- {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/RECORD +198 -200
- myokit/_exec_new.py +0 -15
- myokit/_exec_old.py +0 -15
- {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/LICENSE.txt +0 -0
- {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/WHEEL +0 -0
- {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/entry_points.txt +0 -0
- {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/top_level.txt +0 -0
myokit/gui/vargrapher.py
CHANGED
|
@@ -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
|
-
from __future__ import absolute_import, division
|
|
8
|
-
from __future__ import print_function, unicode_literals
|
|
9
|
-
|
|
10
|
-
# Standard library imports
|
|
11
|
-
|
|
12
|
-
# Myokit
|
|
13
7
|
import myokit
|
|
8
|
+
import myokit.gui
|
|
14
9
|
|
|
15
|
-
# Qt imports
|
|
16
10
|
from myokit.gui import QtGui, QtWidgets
|
|
17
11
|
|
|
18
|
-
# NumPy
|
|
19
12
|
import numpy as np
|
|
20
13
|
|
|
21
|
-
# GUI components
|
|
22
|
-
import myokit.gui
|
|
23
|
-
|
|
24
14
|
# Matplotlib (must be imported _after_ gui has had chance to set backend)
|
|
25
15
|
import matplotlib
|
|
26
16
|
import matplotlib.figure
|
|
@@ -50,7 +40,7 @@ class VarGrapher(QtWidgets.QDialog):
|
|
|
50
40
|
*Extends:* ``QtWidgets.QDialog``
|
|
51
41
|
"""
|
|
52
42
|
def __init__(self, parent, title, var, func, args):
|
|
53
|
-
super(
|
|
43
|
+
super().__init__(parent)
|
|
54
44
|
self.setFixedSize(700, 600)
|
|
55
45
|
self.setWindowTitle(title)
|
|
56
46
|
|
myokit/lib/deps.py
CHANGED
|
@@ -5,12 +5,11 @@
|
|
|
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
|
-
import random
|
|
12
8
|
import collections
|
|
9
|
+
import random
|
|
10
|
+
|
|
13
11
|
import myokit
|
|
12
|
+
|
|
14
13
|
# Don't import pyplot yet, this will crash if no window environment is loaded
|
|
15
14
|
|
|
16
15
|
|
|
@@ -174,7 +173,7 @@ def plot_state_dependency_matrix(
|
|
|
174
173
|
return a
|
|
175
174
|
|
|
176
175
|
|
|
177
|
-
class DiGraph
|
|
176
|
+
class DiGraph:
|
|
178
177
|
"""
|
|
179
178
|
A simple directed graph implementation.
|
|
180
179
|
|
|
@@ -182,7 +181,7 @@ class DiGraph(object):
|
|
|
182
181
|
for example ``matrix=[[0, 1, 1], [0, 1, 0], [0, 0, 0]]``
|
|
183
182
|
"""
|
|
184
183
|
def __init__(self, matrix=None):
|
|
185
|
-
super(
|
|
184
|
+
super().__init__()
|
|
186
185
|
if isinstance(matrix, DiGraph):
|
|
187
186
|
# Clone
|
|
188
187
|
self.nodes = collections.OrderedDict()
|
|
@@ -526,7 +525,7 @@ class DiGraph(object):
|
|
|
526
525
|
return test
|
|
527
526
|
|
|
528
527
|
|
|
529
|
-
class Node
|
|
528
|
+
class Node:
|
|
530
529
|
"""
|
|
531
530
|
Defines a node in a graph
|
|
532
531
|
"""
|
|
@@ -534,7 +533,7 @@ class Node(object):
|
|
|
534
533
|
"""
|
|
535
534
|
Creates a new, graphless node with the given identifier
|
|
536
535
|
"""
|
|
537
|
-
super(
|
|
536
|
+
super().__init__()
|
|
538
537
|
self.graph = None
|
|
539
538
|
self.uid = uid
|
|
540
539
|
self.edgo = set()
|
myokit/lib/guess.py
CHANGED
|
@@ -5,9 +5,8 @@
|
|
|
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
8
|
import collections
|
|
9
|
+
|
|
11
10
|
import myokit
|
|
12
11
|
|
|
13
12
|
|
myokit/lib/hh.py
CHANGED
|
@@ -4,14 +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 numpy as np
|
|
8
|
+
|
|
11
9
|
import myokit
|
|
12
10
|
|
|
13
11
|
|
|
14
|
-
class HHModel
|
|
12
|
+
class HHModel:
|
|
15
13
|
"""
|
|
16
14
|
Represents a Hodgkin-Huxley (HH)-style model of an ion channel, extracted
|
|
17
15
|
from a :class:`myokit.Model`.
|
|
@@ -94,7 +92,7 @@ class HHModel(object):
|
|
|
94
92
|
# A HHModel can return a function to calculate state values, but it never
|
|
95
93
|
# updates its internal state in any way.
|
|
96
94
|
def __init__(self, model, states, parameters=None, current=None, vm=None):
|
|
97
|
-
super(
|
|
95
|
+
super().__init__()
|
|
98
96
|
|
|
99
97
|
#
|
|
100
98
|
# Check input
|
|
@@ -533,7 +531,7 @@ class HHModel(object):
|
|
|
533
531
|
return self._steady_state_function(*inputs)
|
|
534
532
|
|
|
535
533
|
|
|
536
|
-
class AnalyticalSimulation
|
|
534
|
+
class AnalyticalSimulation:
|
|
537
535
|
"""
|
|
538
536
|
Analytically evaluates a :class:`HHModel`'s state for a given set of points
|
|
539
537
|
in time.
|
|
@@ -583,7 +581,7 @@ class AnalyticalSimulation(object):
|
|
|
583
581
|
|
|
584
582
|
"""
|
|
585
583
|
def __init__(self, model, protocol=None):
|
|
586
|
-
super(
|
|
584
|
+
super().__init__()
|
|
587
585
|
|
|
588
586
|
# Check model
|
|
589
587
|
if not isinstance(model, HHModel):
|
myokit/lib/markov.py
CHANGED
|
@@ -4,16 +4,14 @@
|
|
|
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
|
|
8
|
+
|
|
11
9
|
import numpy as np
|
|
12
10
|
|
|
13
11
|
import myokit
|
|
14
12
|
|
|
15
13
|
|
|
16
|
-
class LinearModel
|
|
14
|
+
class LinearModel:
|
|
17
15
|
"""
|
|
18
16
|
Represents a linear Markov model of an ion channel extracted from a
|
|
19
17
|
:class:`myokit.Model`.
|
|
@@ -120,7 +118,7 @@ class LinearModel(object):
|
|
|
120
118
|
# for its default values or newly passed in values, but it never updates
|
|
121
119
|
# its internal state in any way!
|
|
122
120
|
def __init__(self, model, states, parameters=None, current=None, vm=None):
|
|
123
|
-
super(
|
|
121
|
+
super().__init__()
|
|
124
122
|
|
|
125
123
|
# Get a clone of the model, with all markov models written in full ODE
|
|
126
124
|
# form.
|
|
@@ -389,7 +387,7 @@ class LinearModel(object):
|
|
|
389
387
|
globl = {'numpy': np, 'n': n}
|
|
390
388
|
local = {}
|
|
391
389
|
|
|
392
|
-
|
|
390
|
+
exec(code, globl, local)
|
|
393
391
|
self._matrix_function = local['matrix_function']
|
|
394
392
|
|
|
395
393
|
#
|
|
@@ -408,7 +406,7 @@ class LinearModel(object):
|
|
|
408
406
|
code = head + '\n' + '\n'.join([' ' + line for line in body])
|
|
409
407
|
globl = {'numpy': np}
|
|
410
408
|
local = {}
|
|
411
|
-
|
|
409
|
+
exec(code, globl, local)
|
|
412
410
|
self._rate_list_function = local['rate_list_function']
|
|
413
411
|
|
|
414
412
|
def current(self):
|
|
@@ -635,7 +633,7 @@ class LinearModel(object):
|
|
|
635
633
|
return x
|
|
636
634
|
|
|
637
635
|
|
|
638
|
-
class AnalyticalSimulation
|
|
636
|
+
class AnalyticalSimulation:
|
|
639
637
|
"""
|
|
640
638
|
Analytically evaluates a :class:`LinearModel`'s state over a given set of
|
|
641
639
|
points in time.
|
|
@@ -689,7 +687,7 @@ class AnalyticalSimulation(object):
|
|
|
689
687
|
|
|
690
688
|
"""
|
|
691
689
|
def __init__(self, model, protocol=None):
|
|
692
|
-
super(
|
|
690
|
+
super().__init__()
|
|
693
691
|
# Check model
|
|
694
692
|
if not isinstance(model, LinearModel):
|
|
695
693
|
raise ValueError('First parameter must be a `LinearModel`.')
|
|
@@ -1093,7 +1091,7 @@ class AnalyticalSimulation(object):
|
|
|
1093
1091
|
return list(self._state)
|
|
1094
1092
|
|
|
1095
1093
|
|
|
1096
|
-
class DiscreteSimulation
|
|
1094
|
+
class DiscreteSimulation:
|
|
1097
1095
|
"""
|
|
1098
1096
|
Performs stochastic simulations of a :class:`LinearModel`'s behavior for a
|
|
1099
1097
|
finite number of channels.
|
|
@@ -1563,7 +1561,7 @@ class DiscreteSimulation(object):
|
|
|
1563
1561
|
return list(self._state)
|
|
1564
1562
|
|
|
1565
1563
|
|
|
1566
|
-
class MarkovModel
|
|
1564
|
+
class MarkovModel:
|
|
1567
1565
|
"""
|
|
1568
1566
|
**Deprecated**: This class has been replaced by the classes
|
|
1569
1567
|
:class:`LinearModel` and :class:`AnalyticalSimulation`. Please update your
|
myokit/lib/multi.py
CHANGED
|
@@ -4,11 +4,9 @@
|
|
|
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 os
|
|
9
8
|
|
|
10
9
|
import myokit
|
|
11
|
-
import os
|
|
12
10
|
|
|
13
11
|
|
|
14
12
|
#
|
myokit/lib/plots.py
CHANGED
|
@@ -5,10 +5,8 @@
|
|
|
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
|
import numpy as np
|
|
9
|
+
|
|
12
10
|
# Don't import pyplot yet, this will cause a crash if no window environment
|
|
13
11
|
# is loaded.
|
|
14
12
|
|
myokit/pacing.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
|
|
11
8
|
"""
|
|
12
9
|
This module contains factory methods to create Protocol objects
|
myokit/pype.py
CHANGED
|
@@ -4,25 +4,14 @@
|
|
|
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 ast
|
|
8
|
+
import io
|
|
11
9
|
import re
|
|
12
10
|
import sys
|
|
13
11
|
import traceback
|
|
14
12
|
|
|
15
|
-
import myokit
|
|
16
|
-
|
|
17
|
-
try:
|
|
18
|
-
# Python 2
|
|
19
|
-
from cStringIO import StringIO
|
|
20
|
-
except ImportError:
|
|
21
|
-
# Python3
|
|
22
|
-
from io import StringIO
|
|
23
|
-
|
|
24
13
|
|
|
25
|
-
class TemplateEngine
|
|
14
|
+
class TemplateEngine:
|
|
26
15
|
"""
|
|
27
16
|
A tiny templating engine using a php style syntax.
|
|
28
17
|
|
|
@@ -40,7 +29,7 @@ class TemplateEngine(object):
|
|
|
40
29
|
stream specified by the user.
|
|
41
30
|
"""
|
|
42
31
|
def __init__(self):
|
|
43
|
-
super(
|
|
32
|
+
super().__init__()
|
|
44
33
|
self.stream = None
|
|
45
34
|
self.error = None
|
|
46
35
|
|
|
@@ -71,8 +60,8 @@ class TemplateEngine(object):
|
|
|
71
60
|
script = self._convert(filename)
|
|
72
61
|
|
|
73
62
|
# Get or create output stream
|
|
74
|
-
stdout = self.stream if self.stream else StringIO()
|
|
75
|
-
stderr = StringIO()
|
|
63
|
+
stdout = self.stream if self.stream else io.StringIO()
|
|
64
|
+
stderr = io.StringIO()
|
|
76
65
|
|
|
77
66
|
# Run and handle errors
|
|
78
67
|
error = None
|
|
@@ -84,7 +73,7 @@ class TemplateEngine(object):
|
|
|
84
73
|
syserr = sys.stderr
|
|
85
74
|
sys.stdout = stdout
|
|
86
75
|
sys.stderr = stderr
|
|
87
|
-
|
|
76
|
+
exec(script, variables)
|
|
88
77
|
except Exception:
|
|
89
78
|
error = sys.exc_info()
|
|
90
79
|
finally:
|
|
@@ -245,5 +234,5 @@ class PypeError(Exception):
|
|
|
245
234
|
*Extends:* Exception
|
|
246
235
|
"""
|
|
247
236
|
def __init__(self, message):
|
|
248
|
-
super(
|
|
237
|
+
super().__init__(message)
|
|
249
238
|
|
myokit/tests/__init__.py
CHANGED
|
@@ -8,9 +8,6 @@
|
|
|
8
8
|
# The TemporaryDirectory class was adapted from Pints
|
|
9
9
|
# See: https://github.com/pints-team/pints
|
|
10
10
|
#
|
|
11
|
-
from __future__ import absolute_import, division
|
|
12
|
-
from __future__ import print_function, unicode_literals
|
|
13
|
-
|
|
14
11
|
import os
|
|
15
12
|
import tempfile
|
|
16
13
|
import warnings
|
|
@@ -43,14 +40,14 @@ if OpenCL_FOUND:
|
|
|
43
40
|
del info
|
|
44
41
|
|
|
45
42
|
|
|
46
|
-
class TemporaryDirectory
|
|
43
|
+
class TemporaryDirectory:
|
|
47
44
|
"""
|
|
48
45
|
ContextManager that provides a temporary directory to create temporary
|
|
49
46
|
files in. Deletes the directory and its contents when the context is
|
|
50
47
|
exited.
|
|
51
48
|
"""
|
|
52
49
|
def __init__(self):
|
|
53
|
-
super(
|
|
50
|
+
super().__init__()
|
|
54
51
|
self._dir = None
|
|
55
52
|
|
|
56
53
|
def __enter__(self):
|
|
@@ -138,7 +135,7 @@ class CancellingReporter(myokit.ProgressReporter):
|
|
|
138
135
|
return self.okays >= 0
|
|
139
136
|
|
|
140
137
|
|
|
141
|
-
class WarningCollector
|
|
138
|
+
class WarningCollector:
|
|
142
139
|
"""
|
|
143
140
|
Wrapper around warnings.catch_warnings() that gathers all messages into a
|
|
144
141
|
single string.
|
|
@@ -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
|
import os
|
|
12
9
|
|
|
13
10
|
import myokit
|
|
@@ -26,7 +23,7 @@ class AnsicEventBasedPacing(myokit.CModule):
|
|
|
26
23
|
_index = 0
|
|
27
24
|
|
|
28
25
|
def __init__(self, protocol):
|
|
29
|
-
super(
|
|
26
|
+
super().__init__()
|
|
30
27
|
|
|
31
28
|
# Unique id
|
|
32
29
|
AnsicEventBasedPacing._index += 1
|
|
@@ -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
|
import os
|
|
12
9
|
|
|
13
10
|
import myokit
|
|
@@ -25,7 +22,7 @@ class AnsicFixedFormPacing(myokit.CModule):
|
|
|
25
22
|
_index = 0
|
|
26
23
|
|
|
27
24
|
def __init__(self, protocol):
|
|
28
|
-
super(
|
|
25
|
+
super().__init__()
|
|
29
26
|
|
|
30
27
|
# Unique id
|
|
31
28
|
AnsicFixedFormPacing._index += 1
|
myokit/tests/test_aux.py
CHANGED
|
@@ -5,25 +5,11 @@
|
|
|
5
5
|
# This file is part of Myokit.
|
|
6
6
|
# See http://myokit.org for copyright, sharing, and licensing details.
|
|
7
7
|
#
|
|
8
|
-
|
|
9
|
-
from __future__ import print_function, unicode_literals
|
|
10
|
-
|
|
8
|
+
import io
|
|
11
9
|
import os
|
|
12
10
|
import re
|
|
13
11
|
import unittest
|
|
14
12
|
|
|
15
|
-
# StringIO in Python 2 and 3
|
|
16
|
-
try:
|
|
17
|
-
from cStringIO import StringIO
|
|
18
|
-
except ImportError: # pragma: no python 2 cover
|
|
19
|
-
from io import StringIO
|
|
20
|
-
|
|
21
|
-
# Strings in Python2 and Python3
|
|
22
|
-
try:
|
|
23
|
-
basestring
|
|
24
|
-
except NameError: # pragma: no cover
|
|
25
|
-
basestring = str
|
|
26
|
-
|
|
27
13
|
import myokit
|
|
28
14
|
|
|
29
15
|
from myokit.tests import DIR_DATA, WarningCollector
|
|
@@ -87,7 +73,7 @@ class AuxTest(unittest.TestCase):
|
|
|
87
73
|
|
|
88
74
|
# Test without a model
|
|
89
75
|
script = myokit.default_script()
|
|
90
|
-
self.assertTrue(isinstance(script,
|
|
76
|
+
self.assertTrue(isinstance(script, str))
|
|
91
77
|
self.assertIn('run(1000)', script)
|
|
92
78
|
|
|
93
79
|
# Test adapting the time unit
|
|
@@ -95,29 +81,29 @@ class AuxTest(unittest.TestCase):
|
|
|
95
81
|
t = model.add_component('c').add_variable('t')
|
|
96
82
|
t.set_rhs(0)
|
|
97
83
|
script = myokit.default_script(model)
|
|
98
|
-
self.assertTrue(isinstance(script,
|
|
84
|
+
self.assertTrue(isinstance(script, str))
|
|
99
85
|
self.assertIn('run(1000)', script)
|
|
100
86
|
|
|
101
87
|
t.set_binding('time')
|
|
102
88
|
script = myokit.default_script(model)
|
|
103
|
-
self.assertTrue(isinstance(script,
|
|
89
|
+
self.assertTrue(isinstance(script, str))
|
|
104
90
|
self.assertIn('run(1000)', script)
|
|
105
91
|
|
|
106
92
|
t.set_unit('s')
|
|
107
93
|
script = myokit.default_script(model)
|
|
108
|
-
self.assertTrue(isinstance(script,
|
|
94
|
+
self.assertTrue(isinstance(script, str))
|
|
109
95
|
self.assertIn('run(1.0)', script)
|
|
110
96
|
|
|
111
97
|
t.set_unit('ms')
|
|
112
98
|
script = myokit.default_script(model)
|
|
113
|
-
self.assertTrue(isinstance(script,
|
|
99
|
+
self.assertTrue(isinstance(script, str))
|
|
114
100
|
self.assertIn('run(1000)', script)
|
|
115
101
|
|
|
116
102
|
# Test plotting membrane potential
|
|
117
103
|
v = model.get('c').add_variable('v')
|
|
118
104
|
v.set_label('membrane_potential')
|
|
119
105
|
script = myokit.default_script(model)
|
|
120
|
-
self.assertTrue(isinstance(script,
|
|
106
|
+
self.assertTrue(isinstance(script, str))
|
|
121
107
|
self.assertIn("var = 'c.v'", script)
|
|
122
108
|
|
|
123
109
|
# TODO: Run with tiny model?
|
|
@@ -283,7 +269,7 @@ class AuxTest(unittest.TestCase):
|
|
|
283
269
|
|
|
284
270
|
# Test with stringio
|
|
285
271
|
x = "print('Hi there')"
|
|
286
|
-
s = StringIO()
|
|
272
|
+
s = io.StringIO()
|
|
287
273
|
with myokit.tools.capture() as c:
|
|
288
274
|
myokit.run(m, p, x, stderr=s, stdout=s)
|
|
289
275
|
self.assertEqual(c.text(), '')
|
|
@@ -563,7 +549,7 @@ class AuxTest(unittest.TestCase):
|
|
|
563
549
|
|
|
564
550
|
# Raw version
|
|
565
551
|
raw = myokit.version(raw=True)
|
|
566
|
-
self.assertIsInstance(raw,
|
|
552
|
+
self.assertIsInstance(raw, str)
|
|
567
553
|
parts = raw.split('.')
|
|
568
554
|
self.assertTrue(len(parts) in [3, 4])
|
|
569
555
|
|
|
@@ -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
|
import unittest
|
|
12
9
|
|
|
13
10
|
import myokit
|
|
@@ -15,18 +12,6 @@ import myokit.formats.cellml.v1 as cellml
|
|
|
15
12
|
|
|
16
13
|
from myokit.tests import WarningCollector
|
|
17
14
|
|
|
18
|
-
# Unit testing in Python 2 and 3
|
|
19
|
-
try:
|
|
20
|
-
unittest.TestCase.assertRaisesRegex
|
|
21
|
-
except AttributeError:
|
|
22
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
23
|
-
|
|
24
|
-
# Strings in Python2 and Python3
|
|
25
|
-
try:
|
|
26
|
-
basestring
|
|
27
|
-
except NameError: # pragma: no cover
|
|
28
|
-
basestring = str
|
|
29
|
-
|
|
30
15
|
|
|
31
16
|
class TestCellML1AnnotatedElement(unittest.TestCase):
|
|
32
17
|
""" Tests for cellml.AnnotatableElement. """
|
|
@@ -1503,7 +1488,7 @@ class TestCellML1Units(unittest.TestCase):
|
|
|
1503
1488
|
names = [x for x in cellml.Units.si_unit_names()]
|
|
1504
1489
|
self.assertTrue(len(names) > 10)
|
|
1505
1490
|
for name in names:
|
|
1506
|
-
self.assertTrue(isinstance(name,
|
|
1491
|
+
self.assertTrue(isinstance(name, str))
|
|
1507
1492
|
if name == 'celsius':
|
|
1508
1493
|
continue
|
|
1509
1494
|
self.assertTrue(
|
|
@@ -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
|
import os
|
|
12
9
|
import unittest
|
|
13
10
|
|
|
@@ -20,18 +17,6 @@ from myokit.tests import TemporaryDirectory, DIR_FORMATS, WarningCollector
|
|
|
20
17
|
# CellML directory
|
|
21
18
|
DIR = os.path.join(DIR_FORMATS, 'cellml')
|
|
22
19
|
|
|
23
|
-
# Unit testing in Python 2 and 3
|
|
24
|
-
try:
|
|
25
|
-
unittest.TestCase.assertRaisesRegex
|
|
26
|
-
except AttributeError:
|
|
27
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
28
|
-
|
|
29
|
-
# Strings in Python2 and Python3
|
|
30
|
-
try:
|
|
31
|
-
basestring
|
|
32
|
-
except NameError: # pragma: no cover
|
|
33
|
-
basestring = str
|
|
34
|
-
|
|
35
20
|
|
|
36
21
|
class TestCellMLParser(unittest.TestCase):
|
|
37
22
|
""" Tests the CellML 1.0/1.1 parser (mostly for errors). """
|
|
@@ -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
|
import re
|
|
12
9
|
import unittest
|
|
13
10
|
|
|
@@ -16,12 +13,6 @@ import myokit.formats.cellml.v1 as cellml
|
|
|
16
13
|
|
|
17
14
|
from myokit.tests import TemporaryDirectory, WarningCollector
|
|
18
15
|
|
|
19
|
-
# Unit testing in Python 2 and 3
|
|
20
|
-
try:
|
|
21
|
-
unittest.TestCase.assertRaisesRegex
|
|
22
|
-
except AttributeError:
|
|
23
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
24
|
-
|
|
25
16
|
|
|
26
17
|
class TestCellMLWriter(unittest.TestCase):
|
|
27
18
|
""" Tests for cellml.Writer. """
|
|
@@ -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
|
import unittest
|
|
12
9
|
|
|
13
10
|
import myokit
|
|
@@ -15,18 +12,6 @@ import myokit.formats.cellml.v2 as cellml
|
|
|
15
12
|
|
|
16
13
|
from myokit.tests import WarningCollector
|
|
17
14
|
|
|
18
|
-
# Unit testing in Python 2 and 3
|
|
19
|
-
try:
|
|
20
|
-
unittest.TestCase.assertRaisesRegex
|
|
21
|
-
except AttributeError:
|
|
22
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
23
|
-
|
|
24
|
-
# Strings in Python2 and Python3
|
|
25
|
-
try:
|
|
26
|
-
basestring
|
|
27
|
-
except NameError: # pragma: no cover
|
|
28
|
-
basestring = str
|
|
29
|
-
|
|
30
15
|
|
|
31
16
|
class TestCellML2AnnotatableElement(unittest.TestCase):
|
|
32
17
|
""" Tests for ``cellml.v2.AnnotatableElement``. """
|
|
@@ -1810,7 +1795,7 @@ class TestCellML2Units(unittest.TestCase):
|
|
|
1810
1795
|
names = [x for x in cellml.Units.si_unit_names()]
|
|
1811
1796
|
self.assertTrue(len(names) > 10)
|
|
1812
1797
|
for name in names:
|
|
1813
|
-
self.assertTrue(isinstance(name,
|
|
1798
|
+
self.assertTrue(isinstance(name, str))
|
|
1814
1799
|
self.assertTrue(
|
|
1815
1800
|
isinstance(cellml.Units.find_units(name), cellml.Units))
|
|
1816
1801
|
|
|
@@ -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
|
import os
|
|
12
9
|
import unittest
|
|
13
10
|
|
|
@@ -19,18 +16,6 @@ from myokit.tests import TemporaryDirectory, DIR_FORMATS, WarningCollector
|
|
|
19
16
|
# CellML directory
|
|
20
17
|
DIR = os.path.join(DIR_FORMATS, 'cellml')
|
|
21
18
|
|
|
22
|
-
# Unit testing in Python 2 and 3
|
|
23
|
-
try:
|
|
24
|
-
unittest.TestCase.assertRaisesRegex
|
|
25
|
-
except AttributeError:
|
|
26
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
27
|
-
|
|
28
|
-
# Strings in Python2 and Python3
|
|
29
|
-
try:
|
|
30
|
-
basestring
|
|
31
|
-
except NameError: # pragma: no cover
|
|
32
|
-
basestring = str
|
|
33
|
-
|
|
34
19
|
|
|
35
20
|
class TestCellMLParser(unittest.TestCase):
|
|
36
21
|
""" Tests the CellML 2.0 parser (mostly for errors / model validation). """
|
|
@@ -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
|
import re
|
|
12
9
|
import unittest
|
|
13
10
|
|
|
@@ -16,12 +13,6 @@ import myokit.formats.cellml.v2 as cellml
|
|
|
16
13
|
|
|
17
14
|
from myokit.tests import TemporaryDirectory, WarningCollector
|
|
18
15
|
|
|
19
|
-
# Unit testing in Python 2 and 3
|
|
20
|
-
try:
|
|
21
|
-
unittest.TestCase.assertRaisesRegex
|
|
22
|
-
except AttributeError:
|
|
23
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
24
|
-
|
|
25
16
|
|
|
26
17
|
class TestCellMLWriter(unittest.TestCase):
|
|
27
18
|
""" Tests for cellml.Writer. """
|
myokit/tests/test_cmodel.py
CHANGED
|
@@ -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
|
import os
|
|
12
9
|
import unittest
|
|
13
10
|
|
|
@@ -15,12 +12,6 @@ import myokit
|
|
|
15
12
|
|
|
16
13
|
from myokit.tests import DIR_DATA
|
|
17
14
|
|
|
18
|
-
# Unit testing in Python 2 and 3
|
|
19
|
-
try:
|
|
20
|
-
unittest.TestCase.assertRaisesRegex
|
|
21
|
-
except AttributeError:
|
|
22
|
-
unittest.TestCase.assertRaisesRegex = unittest.TestCase.assertRaisesRegexp
|
|
23
|
-
|
|
24
15
|
|
|
25
16
|
class CModelTest(unittest.TestCase):
|
|
26
17
|
"""
|