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.
Files changed (229) hide show
  1. myokit/__init__.py +9 -36
  2. myokit/__main__.py +76 -142
  3. myokit/_aux.py +62 -16
  4. myokit/_bin/example.mmt +1 -2
  5. myokit/_bin/install-win/menu.json +7 -7
  6. myokit/_config.py +22 -31
  7. myokit/_datablock.py +30 -74
  8. myokit/_datalog.py +49 -72
  9. myokit/_err.py +25 -24
  10. myokit/_expressions.py +50 -68
  11. myokit/_io.py +15 -27
  12. myokit/_model_api.py +453 -249
  13. myokit/_myokit_version.py +1 -5
  14. myokit/_parsing.py +38 -44
  15. myokit/_progress.py +5 -8
  16. myokit/_protocol.py +99 -9
  17. myokit/_sim/__init__.py +7 -24
  18. myokit/_sim/cable.c +6 -8
  19. myokit/_sim/cable.py +6 -8
  20. myokit/_sim/cmodel.h +125 -70
  21. myokit/_sim/cmodel.py +12 -14
  22. myokit/_sim/compiler.py +1 -4
  23. myokit/_sim/cvodessim.c +196 -118
  24. myokit/_sim/cvodessim.py +130 -103
  25. myokit/_sim/differential.hpp +4 -4
  26. myokit/_sim/fiber_tissue.c +4 -8
  27. myokit/_sim/fiber_tissue.py +11 -13
  28. myokit/_sim/jacobian.cpp +2 -2
  29. myokit/_sim/jacobian.py +11 -8
  30. myokit/_sim/mcl.h +53 -55
  31. myokit/_sim/opencl.py +21 -27
  32. myokit/_sim/openclsim.c +3 -7
  33. myokit/_sim/openclsim.cl +3 -3
  34. myokit/_sim/openclsim.py +49 -40
  35. myokit/_sim/pacing.h +36 -16
  36. myokit/_sim/rhs.c +6 -13
  37. myokit/_sim/rhs.py +5 -14
  38. myokit/_sim/sundials.py +1 -4
  39. myokit/_system.py +10 -16
  40. myokit/_unit.py +4 -13
  41. myokit/float.py +0 -3
  42. myokit/formats/__init__.py +8 -10
  43. myokit/formats/ansic/__init__.py +0 -3
  44. myokit/formats/ansic/_ewriter.py +2 -4
  45. myokit/formats/ansic/_exporter.py +1 -4
  46. myokit/formats/ansic/template/cable.c +4 -4
  47. myokit/formats/ansic/template/euler.c +5 -5
  48. myokit/formats/ansic/template/sim.c +6 -6
  49. myokit/formats/axon/__init__.py +1 -3
  50. myokit/formats/axon/_abf.py +12 -17
  51. myokit/formats/axon/_atf.py +5 -6
  52. myokit/formats/axon/_importer.py +0 -3
  53. myokit/formats/cellml/__init__.py +0 -3
  54. myokit/formats/cellml/_ewriter.py +3 -6
  55. myokit/formats/cellml/_exporter.py +3 -6
  56. myokit/formats/cellml/_importer.py +1 -4
  57. myokit/formats/cellml/v1/__init__.py +0 -4
  58. myokit/formats/cellml/v1/_api.py +8 -11
  59. myokit/formats/cellml/v1/_parser.py +2 -5
  60. myokit/formats/cellml/v1/_writer.py +2 -11
  61. myokit/formats/cellml/v2/__init__.py +0 -3
  62. myokit/formats/cellml/v2/_api.py +8 -17
  63. myokit/formats/cellml/v2/_parser.py +2 -5
  64. myokit/formats/cellml/v2/_writer.py +1 -4
  65. myokit/formats/channelml/__init__.py +0 -3
  66. myokit/formats/channelml/_importer.py +11 -21
  67. myokit/formats/cpp/__init__.py +1 -3
  68. myokit/formats/cpp/_ewriter.py +0 -3
  69. myokit/formats/cuda/__init__.py +0 -3
  70. myokit/formats/cuda/_ewriter.py +2 -4
  71. myokit/formats/cuda/_exporter.py +0 -3
  72. myokit/formats/cuda/template/kernel.cu +8 -5
  73. myokit/formats/easyml/__init__.py +0 -3
  74. myokit/formats/easyml/_ewriter.py +9 -11
  75. myokit/formats/easyml/_exporter.py +2 -5
  76. myokit/formats/html/__init__.py +0 -3
  77. myokit/formats/html/_exporter.py +0 -3
  78. myokit/formats/html/_flatten.py +5 -21
  79. myokit/formats/latex/__init__.py +0 -3
  80. myokit/formats/latex/_ewriter.py +1 -4
  81. myokit/formats/latex/_exporter.py +4 -6
  82. myokit/formats/mathml/__init__.py +0 -3
  83. myokit/formats/mathml/_ewriter.py +2 -11
  84. myokit/formats/mathml/_parser.py +4 -6
  85. myokit/formats/matlab/__init__.py +0 -3
  86. myokit/formats/matlab/_ewriter.py +1 -4
  87. myokit/formats/matlab/_exporter.py +2 -5
  88. myokit/formats/matlab/template/main.m +3 -2
  89. myokit/formats/opencl/__init__.py +0 -3
  90. myokit/formats/opencl/_ewriter.py +2 -4
  91. myokit/formats/opencl/_exporter.py +2 -5
  92. myokit/formats/opencl/template/cable.c +10 -10
  93. myokit/formats/opencl/template/kernel.cl +1 -1
  94. myokit/formats/opencl/template/minilog.py +1 -1
  95. myokit/formats/python/__init__.py +0 -3
  96. myokit/formats/python/_ewriter.py +2 -5
  97. myokit/formats/python/_exporter.py +0 -3
  98. myokit/formats/python/template/sim.py +14 -14
  99. myokit/formats/sbml/__init__.py +0 -3
  100. myokit/formats/sbml/_api.py +50 -44
  101. myokit/formats/sbml/_importer.py +1 -4
  102. myokit/formats/sbml/_parser.py +2 -5
  103. myokit/formats/stan/__init__.py +0 -3
  104. myokit/formats/stan/_ewriter.py +2 -4
  105. myokit/formats/stan/_exporter.py +2 -5
  106. myokit/formats/stan/template/cell.stan +3 -3
  107. myokit/formats/sympy/__init__.py +0 -3
  108. myokit/formats/sympy/_ereader.py +1 -4
  109. myokit/formats/sympy/_ewriter.py +2 -5
  110. myokit/formats/wcp/__init__.py +0 -3
  111. myokit/formats/wcp/_wcp.py +2 -8
  112. myokit/formats/xml/__init__.py +0 -3
  113. myokit/formats/xml/_exporter.py +0 -3
  114. myokit/formats/xml/_split.py +0 -3
  115. myokit/gui/__init__.py +80 -246
  116. myokit/gui/datablock_viewer.py +103 -86
  117. myokit/gui/datalog_viewer.py +214 -66
  118. myokit/gui/explorer.py +15 -21
  119. myokit/gui/ide.py +171 -144
  120. myokit/gui/progress.py +9 -9
  121. myokit/gui/source.py +406 -375
  122. myokit/gui/vargrapher.py +2 -12
  123. myokit/lib/deps.py +12 -13
  124. myokit/lib/guess.py +3 -4
  125. myokit/lib/hh.py +20 -18
  126. myokit/lib/markov.py +21 -20
  127. myokit/lib/multi.py +1 -3
  128. myokit/lib/plots.py +20 -9
  129. myokit/pacing.py +0 -3
  130. myokit/pype.py +7 -18
  131. myokit/tests/__init__.py +3 -6
  132. myokit/tests/ansic_event_based_pacing.py +1 -4
  133. myokit/tests/ansic_fixed_form_pacing.py +3 -6
  134. myokit/tests/data/beeler-1977-model-compare-b.mmt +2 -2
  135. myokit/tests/data/clancy-1999-fitting.mmt +1 -0
  136. myokit/tests/test_aux.py +13 -28
  137. myokit/tests/test_cellml_v1_api.py +4 -19
  138. myokit/tests/test_cellml_v1_parser.py +0 -15
  139. myokit/tests/test_cellml_v1_writer.py +0 -9
  140. myokit/tests/test_cellml_v2_api.py +4 -19
  141. myokit/tests/test_cellml_v2_parser.py +0 -15
  142. myokit/tests/test_cellml_v2_writer.py +0 -9
  143. myokit/tests/test_cmodel.py +16 -22
  144. myokit/tests/test_compiler_detection.py +1 -11
  145. myokit/tests/test_component.py +108 -56
  146. myokit/tests/test_config.py +34 -67
  147. myokit/tests/test_datablock.py +1 -9
  148. myokit/tests/test_datalog.py +19 -24
  149. myokit/tests/test_dependency_checking.py +8 -23
  150. myokit/tests/test_expressions.py +0 -9
  151. myokit/tests/test_float.py +1 -5
  152. myokit/tests/test_formats.py +0 -9
  153. myokit/tests/test_formats_axon.py +1 -9
  154. myokit/tests/test_formats_cellml.py +0 -15
  155. myokit/tests/test_formats_channelml.py +0 -15
  156. myokit/tests/test_formats_easyml.py +0 -14
  157. myokit/tests/test_formats_exporters.py +1 -16
  158. myokit/tests/test_formats_expression_writers.py +1 -17
  159. myokit/tests/test_formats_html.py +0 -3
  160. myokit/tests/test_formats_importers.py +1 -16
  161. myokit/tests/test_formats_mathml_content.py +0 -9
  162. myokit/tests/test_formats_mathml_presentation.py +0 -9
  163. myokit/tests/test_formats_opencl.py +0 -10
  164. myokit/tests/test_formats_sbml.py +0 -15
  165. myokit/tests/test_formats_sympy.py +0 -9
  166. myokit/tests/test_formats_wcp.py +1 -3
  167. myokit/tests/test_io.py +27 -27
  168. myokit/tests/test_jacobian_calculator.py +6 -14
  169. myokit/tests/test_jacobian_tracer.py +0 -9
  170. myokit/tests/test_lib_deps.py +0 -9
  171. myokit/tests/test_lib_guess.py +0 -9
  172. myokit/tests/test_lib_hh.py +18 -12
  173. myokit/tests/test_lib_markov.py +21 -13
  174. myokit/tests/test_lib_multi.py +0 -9
  175. myokit/tests/test_lib_plots.py +13 -8
  176. myokit/tests/test_meta.py +0 -3
  177. myokit/tests/test_model.py +390 -96
  178. myokit/tests/test_model_building.py +44 -96
  179. myokit/tests/test_opencl_info.py +5 -14
  180. myokit/tests/test_pacing_factory.py +0 -3
  181. myokit/tests/test_pacing_system_c.py +1 -23
  182. myokit/tests/test_pacing_system_py.py +0 -9
  183. myokit/tests/test_parsing.py +139 -56
  184. myokit/tests/test_progress_reporters.py +0 -3
  185. myokit/tests/test_protocol.py +0 -9
  186. myokit/tests/test_protocol_floating_point.py +1 -10
  187. myokit/tests/test_protocol_time_series.py +82 -0
  188. myokit/tests/test_pype.py +0 -9
  189. myokit/tests/test_quantity.py +0 -9
  190. myokit/tests/test_rhs_benchmarker.py +1 -9
  191. myokit/tests/test_sbml_api.py +27 -42
  192. myokit/tests/test_sbml_parser.py +4 -19
  193. myokit/tests/test_simulation_1d.py +45 -25
  194. myokit/tests/test_simulation_cvodes.py +321 -55
  195. myokit/tests/test_simulation_cvodes_from_disk.py +0 -3
  196. myokit/tests/test_simulation_fiber_tissue.py +39 -12
  197. myokit/tests/test_simulation_log_interval.py +1 -431
  198. myokit/tests/test_simulation_opencl.py +69 -48
  199. myokit/tests/test_simulation_opencl_log_interval.py +1 -3
  200. myokit/tests/test_simulation_opencl_vs_cvode.py +1 -10
  201. myokit/tests/test_simulation_opencl_vs_sim1d.py +1 -10
  202. myokit/tests/test_system_info.py +1 -11
  203. myokit/tests/test_tools.py +0 -9
  204. myokit/tests/test_unit.py +1 -10
  205. myokit/tests/test_user_functions.py +0 -10
  206. myokit/tests/test_variable.py +231 -27
  207. myokit/tools.py +5 -21
  208. myokit/units.py +5 -3
  209. {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/METADATA +12 -15
  210. myokit-1.35.0.dist-info/RECORD +391 -0
  211. {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/WHEEL +1 -1
  212. {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/entry_points.txt +0 -1
  213. myokit/_exec_new.py +0 -15
  214. myokit/_exec_old.py +0 -15
  215. myokit/_sim/cvodesim.c +0 -1551
  216. myokit/_sim/cvodesim.py +0 -674
  217. myokit/_sim/icsim.cpp +0 -563
  218. myokit/_sim/icsim.py +0 -363
  219. myokit/_sim/psim.cpp +0 -656
  220. myokit/_sim/psim.py +0 -493
  221. myokit/lib/common.py +0 -1094
  222. myokit/tests/test_lib_common.py +0 -130
  223. myokit/tests/test_simulation_cvode.py +0 -612
  224. myokit/tests/test_simulation_ic.py +0 -108
  225. myokit/tests/test_simulation_p.py +0 -223
  226. myokit-1.33.9.dist-info/RECORD +0 -403
  227. /myokit/formats/opencl/template/{test → test.sh} +0 -0
  228. {myokit-1.33.9.dist-info → myokit-1.35.0.dist-info}/LICENSE.txt +0 -0
  229. {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 CudaKernelExporter, CudaKernelRLExporter
11
8
  from ._ewriter import CudaExpressionWriter
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 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(CudaExpressionWriter, self).__init__()
18
+ super().__init__()
21
19
  self._function_prefix = ''
22
20
  self._sp = (precision == myokit.SINGLE_PRECISION)
23
21
 
@@ -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
@@ -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 = model.prepare_bindings({
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.indice()) + ']')
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(var.state_value()) + ';')
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(EasyMLExpressionWriter, self).__init__()
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(EasyMLExpressionWriter, self)._ex_minus(e)
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(EasyMLExpressionWriter, self)._ex_sin(e)
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(EasyMLExpressionWriter, self)._ex_tan(e)
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(EasyMLExpressionWriter, self)._ex_asin(e)
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(EasyMLExpressionWriter, self)._ex_atan(e)
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(EasyMLExpressionWriter, self)._ex_floor(e)
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(EasyMLExpressionWriter, self)._ex_ceil(e)
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 = ' + myokit.float.str(v.state_value())
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
@@ -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
 
@@ -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
@@ -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
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
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
- if sys.hexversion < 0x03000000: # pragma: no python 3 cover
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 = self.unescape('&' + name + ';')
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')
@@ -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
 
@@ -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(LatexExpressionWriter, self).__init__()
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(PdfExporter, self).__init__()
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(myokit.Number(v.state_value())))
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(PosterExporter, self).__init__()
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(MathMLExpressionWriter, self).__init__()
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, basestring):
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
@@ -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(MathMLError, self).__init__(message)
64
+ super().__init__(message)
67
65
 
68
66
 
69
- class MathMLParser(object):
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
- behaviour is undefined.
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(MatlabExpressionWriter, self).__init__()
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().indice()) + ')'
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 = model.prepare_bindings({
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 eq in model.inits():
19
- print(e(eq) + ';')
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(OpenCLExpressionWriter, self).__init__()
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 = model.prepare_bindings({
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.state_value()) + '; s++; // ' + str(v.qname()))
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.indice()) + ']')
143
+ print('#define ' + var.uname() + ' state[offset + ' + str(var.index()) + ']')
144
144
 
145
145
  print('')
146
146
  for comp, ilist in comp_in.items():
@@ -69,7 +69,7 @@ class DataLog(OrderedDict):
69
69
  # Delimiters
70
70
  quote = '"'
71
71
  delim = ','
72
- with open(filename, 'rb') as f:
72
+ with open(filename, 'r', newline=None) as f:
73
73
  # Read header
74
74
  keys = []
75
75
  try: