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
@@ -139,23 +139,22 @@
139
139
  # Information - but no direct code - from the matlab script get_abf_header.m
140
140
  # was also used: http://neurodata.hg.sourceforge.net/hgweb/neurodata/neurodata/
141
141
  #------------------------------------------------------------------------------
142
- from __future__ import absolute_import, division
143
- from __future__ import print_function, unicode_literals
144
-
145
- from collections import OrderedDict
146
- import numpy as np
147
- import traceback
148
142
  import datetime
149
143
  import logging
150
- import struct
151
144
  import os
145
+ import struct
146
+ import traceback
147
+
148
+ import numpy as np
149
+
150
+ from collections import OrderedDict
152
151
 
153
152
 
154
153
  # Encoding for text parts of files
155
154
  _ENC = 'latin-1'
156
155
 
157
156
 
158
- class AbfFile(object):
157
+ class AbfFile:
159
158
  """
160
159
  Represents a read-only Axon Binary Format file (``.abf``), stored at the
161
160
  location pointed to by ``filepath``.
@@ -199,7 +198,6 @@ class AbfFile(object):
199
198
  """
200
199
  def __init__(self, filepath, is_protocol_file=None):
201
200
  # The path to the file and its basename
202
- # Ensure it's a `str` for Python2/3 compatibility
203
201
  filepath = str(filepath)
204
202
  self._filepath = os.path.abspath(filepath)
205
203
  self._filename = os.path.basename(filepath)
@@ -254,7 +252,6 @@ class AbfFile(object):
254
252
  # cases that trigger this error they should be resolved. At the
255
253
  # same time, if it happens to a user we want it to "sort-of work"
256
254
  # (an experimental rather than a production setting)
257
- logging.basicConfig()
258
255
  log = logging.getLogger(__name__)
259
256
  log.warning('Unable to read protocol from ' + self._filepath)
260
257
  log.warning(traceback.format_exc())
@@ -703,7 +700,6 @@ class AbfFile(object):
703
700
  """
704
701
  Read and unpack a file section using the given format ``form``.
705
702
  """
706
- # Form must be a str (so bytes on Python 2)
707
703
  form = str(form)
708
704
  if offset is not None:
709
705
  f.seek(offset)
@@ -1065,7 +1061,6 @@ class AbfFile(object):
1065
1061
 
1066
1062
  else: # pragma: no cover
1067
1063
 
1068
- logging.basicConfig()
1069
1064
  log = logging.getLogger(__name__)
1070
1065
  log.warning(
1071
1066
  'Unsupported epoch type: ' + epoch_types(kind))
@@ -1308,14 +1303,14 @@ class AbfFile(object):
1308
1303
  self._adc_offsets.append(s)
1309
1304
 
1310
1305
 
1311
- class Sweep(object):
1306
+ class Sweep:
1312
1307
  """
1313
1308
  Represents a single sweep (also called an 'episode')
1314
1309
 
1315
1310
  A sweep is represented as a fixed-size list of channels.
1316
1311
  """
1317
1312
  def __init__(self, n):
1318
- super(Sweep, self).__init__()
1313
+ super().__init__()
1319
1314
  n = int(n)
1320
1315
  if n < 0: # pragma: no cover
1321
1316
  raise ValueError('Number channels cannot be negative.')
@@ -1338,14 +1333,14 @@ class Sweep(object):
1338
1333
  self._channels[key] = value
1339
1334
 
1340
1335
 
1341
- class Channel(object):
1336
+ class Channel:
1342
1337
  """
1343
1338
  Represents an analog signal for a single channel.
1344
1339
 
1345
1340
  To obtain this channel's formatted data, use times() and trace()
1346
1341
  """
1347
1342
  def __init__(self, parent_file):
1348
- super(Channel, self).__init__()
1343
+ super().__init__()
1349
1344
  self._parent_file = parent_file # The abf file this channel is from
1350
1345
  self._type = TYPE_UNKNOWN # Type of recording
1351
1346
 
@@ -1388,7 +1383,7 @@ class Channel(object):
1388
1383
  def number(self):
1389
1384
  """
1390
1385
  Returns the channel index used by pClamp. Note that this does not
1391
- necessarily equal its index in the python sweep data!
1386
+ necessarily equal its index in the Python sweep data!
1392
1387
  """
1393
1388
  return self._numb
1394
1389
 
@@ -4,20 +4,19 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
- from collections import OrderedDict
11
- import numpy as np
12
7
  import os
13
8
  import re
14
9
 
10
+ import numpy as np
11
+
12
+ from collections import OrderedDict
13
+
15
14
 
16
15
  # Format used for any text
17
16
  _ENC = 'ascii'
18
17
 
19
18
 
20
- class AtfFile(object):
19
+ class AtfFile:
21
20
  """
22
21
  Represents an Axon Text File (ATF) stored on disk.
23
22
 
@@ -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
 
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from ._exporter import CellMLExporter, CellML1Exporter, CellML2Exporter
11
8
  from ._ewriter import CellMLExpressionWriter
12
9
  from ._importer import CellMLImporter, CellMLImporterError # noqa
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from lxml import etree
11
8
 
12
9
  import myokit
@@ -24,8 +21,8 @@ class CellMLExpressionWriter(MathMLExpressionWriter):
24
21
  unit names with :meth:`set_unit_function()`.
25
22
  """
26
23
  def __init__(self, version='1.0'):
27
- super(CellMLExpressionWriter, self).__init__()
28
- super(CellMLExpressionWriter, self).set_mode(presentation=False)
24
+ super().__init__()
25
+ super().set_mode(presentation=False)
29
26
 
30
27
  # Units lookup method
31
28
  self._funits = None
@@ -54,7 +51,7 @@ class CellMLExpressionWriter(MathMLExpressionWriter):
54
51
  self._funits = f
55
52
 
56
53
  def _ex_number(self, e, t):
57
- x = super(CellMLExpressionWriter, self)._ex_number(e, t)
54
+ x = super()._ex_number(e, t)
58
55
  unit = e.unit()
59
56
  if self._funits is not None and unit is not None:
60
57
  units = self._funits(e.unit())
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import myokit
11
8
  import myokit.lib.guess
12
9
 
@@ -18,7 +15,7 @@ class CellMLExporter(myokit.formats.Exporter):
18
15
  This:class:`Exporter <myokit.formats.Exporter>` creates a CellML model.
19
16
  """
20
17
  def __init__(self):
21
- super(CellMLExporter, self).__init__()
18
+ super().__init__()
22
19
 
23
20
  def model(self, path, model, protocol=None, version='1.0'):
24
21
  """
@@ -69,7 +66,7 @@ class CellML1Exporter(CellMLExporter):
69
66
  This:class:`Exporter <myokit.formats.Exporter>` creates a CellML 1.0 model.
70
67
  """
71
68
  def model(self, path, model, protocol=None):
72
- super(CellML1Exporter, self).model(path, model, protocol, '1.0')
69
+ super().model(path, model, protocol, '1.0')
73
70
 
74
71
 
75
72
  class CellML2Exporter(CellMLExporter):
@@ -77,5 +74,5 @@ class CellML2Exporter(CellMLExporter):
77
74
  This:class:`Exporter <myokit.formats.Exporter>` creates a CellML 2.0 model.
78
75
  """
79
76
  def model(self, path, model, protocol=None):
80
- super(CellML2Exporter, self).model(path, model, protocol, '2.0')
77
+ super().model(path, model, protocol, '2.0')
81
78
 
@@ -5,9 +5,6 @@
5
5
  # This file is part of Myokit.
6
6
  # See http://myokit.org for copyright, sharing, and licensing details.
7
7
  #
8
- from __future__ import absolute_import, division
9
- from __future__ import print_function, unicode_literals
10
-
11
8
  from lxml import etree
12
9
 
13
10
  import myokit
@@ -28,7 +25,7 @@ class CellMLImporter(myokit.formats.Importer):
28
25
  from CellML.
29
26
  """
30
27
  def __init__(self, verbose=False):
31
- super(CellMLImporter, self).__init__()
28
+ super().__init__()
32
29
 
33
30
  def model(self, path):
34
31
  """
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from ._api import ( # noqa
11
8
  AnnotatableElement,
12
9
  CellMLError,
@@ -22,7 +19,6 @@ from ._api import ( # noqa
22
19
  is_valid_identifier,
23
20
  )
24
21
 
25
-
26
22
  from ._parser import ( # noqa
27
23
  parse_file,
28
24
  parse_string,
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import collections
11
8
  import re
12
9
  import warnings
@@ -116,7 +113,7 @@ def create_unit_name(unit):
116
113
  return name
117
114
 
118
115
 
119
- class AnnotatableElement(object):
116
+ class AnnotatableElement:
120
117
  """
121
118
  Represents a CellML 1.0 or 1.1 element that can have a cmeta:id.
122
119
 
@@ -187,7 +184,7 @@ class UnsupportedBaseUnitsError(UnitsError):
187
184
  """
188
185
  def __init__(self, units):
189
186
  self.units = units
190
- super(UnsupportedBaseUnitsError, self).__init__(
187
+ super().__init__(
191
188
  'Unsupported base units "' + units + '".')
192
189
 
193
190
 
@@ -196,7 +193,7 @@ class UnsupportedUnitOffsetError(UnitsError):
196
193
  Raised when units with non-zero offsets are used.
197
194
  """
198
195
  def __init__(self):
199
- super(UnsupportedUnitOffsetError, self).__init__(
196
+ super().__init__(
200
197
  'Units with non-zero offsets are not supported.')
201
198
 
202
199
 
@@ -206,7 +203,7 @@ class Component(AnnotatableElement):
206
203
  :meth:`Model.add_component()`.
207
204
  """
208
205
  def __init__(self, model, name):
209
- super(Component, self).__init__(model)
206
+ super().__init__(model)
210
207
 
211
208
  # Store model
212
209
  self._model = model
@@ -474,7 +471,7 @@ class Model(AnnotatableElement):
474
471
 
475
472
  """
476
473
  def __init__(self, name, version='1.0'):
477
- super(Model, self).__init__(self)
474
+ super().__init__(self)
478
475
 
479
476
  # Check and store name
480
477
  if not is_valid_identifier(name):
@@ -898,7 +895,7 @@ class Model(AnnotatableElement):
898
895
  # Promote states and set rhs and initial value
899
896
  elif variable.is_state():
900
897
  v.set_is_state(True)
901
- v.set_initial_value(variable.state_value())
898
+ v.set_initial_value(variable.initial_value(True))
902
899
  v.set_rhs(rhs)
903
900
 
904
901
  # Store literals (single number) in initial value
@@ -1165,7 +1162,7 @@ class Model(AnnotatableElement):
1165
1162
  return self._version
1166
1163
 
1167
1164
 
1168
- class Units(object):
1165
+ class Units:
1169
1166
  """
1170
1167
  Represents a CellML units definition, should not be created directly but
1171
1168
  only via :meth:`Model.add_units()` or :meth:`Component.add_units()`.
@@ -1470,7 +1467,7 @@ class Variable(AnnotatableElement):
1470
1467
  """
1471
1468
  def __init__(self, component, name, units, public_interface='none',
1472
1469
  private_interface='none'):
1473
- super(Variable, self).__init__(component.model())
1470
+ super().__init__(component.model())
1474
1471
 
1475
1472
  # Store component
1476
1473
  self._component = component
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import collections
11
8
  import warnings
12
9
 
@@ -60,10 +57,10 @@ class CellMLParsingError(myokit.ImportError):
60
57
  message = 'Error on line ' + line + '. ' + message
61
58
  except AttributeError:
62
59
  pass
63
- super(CellMLParsingError, self).__init__(message)
60
+ super().__init__(message)
64
61
 
65
62
 
66
- class CellMLParser(object):
63
+ class CellMLParser:
67
64
  """
68
65
  Parses CellML 1.0 and 1.1 documents, and performs (partial) validation of a
69
66
  CellML document.
@@ -4,21 +4,12 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from lxml import etree
8
+ from urllib.parse import quote
11
9
 
12
10
  import myokit
13
11
  import myokit.formats.cellml as cellml
14
12
 
15
- # Quoting URI strings in Python2 and Python3
16
- try:
17
- from urllib.parse import quote
18
- except ImportError: # pragma: no python 3 cover
19
- # Python 2
20
- from urllib import quote
21
-
22
13
 
23
14
  # Left-over from old exporter. Not sure if this had any function.
24
15
  # Add name in 'tmp-documentation' format
@@ -45,7 +36,7 @@ def write_string(model):
45
36
  return CellMLWriter().write_string(model)
46
37
 
47
38
 
48
- class CellMLWriter(object):
39
+ class CellMLWriter:
49
40
  """
50
41
  Writes CellML 1.0 or 1.1 documents.
51
42
  """
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from ._api import ( # noqa
11
8
  AnnotatableElement,
12
9
  CellMLError,
@@ -4,21 +4,12 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import collections
11
8
  import re
12
9
  import warnings
13
10
 
14
11
  import myokit
15
12
 
16
- # Strings in Python2 and Python3
17
- try:
18
- basestring
19
- except NameError: # pragma: no cover
20
- basestring = str
21
-
22
13
 
23
14
  # Data types
24
15
  _cellml_identifier = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$')
@@ -142,7 +133,7 @@ def create_unit_name(unit):
142
133
  return name
143
134
 
144
135
 
145
- class AnnotatableElement(object):
136
+ class AnnotatableElement:
146
137
  """
147
138
  Represents a CellML 2.0 element that can be annotated (using a public dict
148
139
  ``meta`` that stores key:value pairs).
@@ -167,7 +158,7 @@ class Component(AnnotatableElement):
167
158
  :meth:`Model.add_component()`.
168
159
  """
169
160
  def __init__(self, model, name):
170
- super(Component, self).__init__()
161
+ super().__init__()
171
162
 
172
163
  # Store model
173
164
  self._model = model
@@ -323,7 +314,7 @@ class Model(AnnotatableElement):
323
314
 
324
315
  """
325
316
  def __init__(self, name, version='2.0'):
326
- super(Model, self).__init__()
317
+ super().__init__()
327
318
 
328
319
  # Check and store name
329
320
  if not is_identifier(name):
@@ -802,7 +793,7 @@ class Model(AnnotatableElement):
802
793
 
803
794
  # Promote states and set rhs and initial value
804
795
  elif variable.is_state():
805
- v.set_initial_value(variable.state_value())
796
+ v.set_initial_value(variable.initial_value(True))
806
797
  v.set_equation(myokit.Equation(lhs, rhs))
807
798
 
808
799
  # Store literals (single number) in initial value
@@ -1068,7 +1059,7 @@ class Model(AnnotatableElement):
1068
1059
  return self._version
1069
1060
 
1070
1061
 
1071
- class Units(object):
1062
+ class Units:
1072
1063
  """
1073
1064
  Represents a CellML units definition; should not be created directly but
1074
1065
  only via :meth:`Model.add_units()` or :meth:`Component.add_units()`.
@@ -1359,7 +1350,7 @@ class Variable(AnnotatableElement):
1359
1350
 
1360
1351
  """
1361
1352
  def __init__(self, component, name, units, interface='none'):
1362
- super(Variable, self).__init__()
1353
+ super().__init__()
1363
1354
 
1364
1355
  # Store model and component
1365
1356
  self._model = component.model()
@@ -1615,7 +1606,7 @@ class Variable(AnnotatableElement):
1615
1606
  if value is not None:
1616
1607
 
1617
1608
  # Check value is a real number string
1618
- if isinstance(value, basestring):
1609
+ if isinstance(value, str):
1619
1610
  if is_real_number_string(value):
1620
1611
  value = float(value)
1621
1612
  else:
@@ -1642,7 +1633,7 @@ class Variable(AnnotatableElement):
1642
1633
  return self._units
1643
1634
 
1644
1635
 
1645
- class ConnectedVariableSet(object):
1636
+ class ConnectedVariableSet:
1646
1637
  """
1647
1638
  Represents a set of connected variables.
1648
1639
 
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import warnings
11
8
 
12
9
  from lxml import etree
@@ -59,10 +56,10 @@ class CellMLParsingError(myokit.ImportError):
59
56
  message = 'Error on line ' + line + '. ' + message
60
57
  except AttributeError:
61
58
  pass
62
- super(CellMLParsingError, self).__init__(message)
59
+ super().__init__(message)
63
60
 
64
61
 
65
- class CellMLParser(object):
62
+ class CellMLParser:
66
63
  """
67
64
  Parses CellML 2.0 documents, and performs (partial) validation.
68
65
 
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from lxml import etree
11
8
 
12
9
  import myokit
@@ -27,7 +24,7 @@ def write_string(model):
27
24
  return CellMLWriter().write_string(model)
28
25
 
29
26
 
30
- class CellMLWriter(object):
27
+ class CellMLWriter:
31
28
  """
32
29
  Writes CellML 2.0 documents.
33
30
  """
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from ._importer import ChannelMLImporter, ChannelMLError # noqa
11
8
 
12
9
 
@@ -4,23 +4,13 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
7
+ import io
10
8
  import os
11
9
  import textwrap
10
+ import warnings
12
11
  import xml.dom
13
12
  import xml.dom.minidom
14
13
 
15
- import warnings
16
-
17
- try:
18
- # Python 2
19
- from cStringIO import StringIO
20
- except ImportError:
21
- # Python3
22
- from io import StringIO
23
-
24
14
  import myokit
25
15
  from myokit import formats
26
16
  from myokit import Name, Number, Minus, Multiply, Divide, Power
@@ -71,7 +61,7 @@ class ChannelMLImporter(formats.Importer):
71
61
  from the ChannelML format.
72
62
  """
73
63
  def __init__(self, verbose=False):
74
- super(ChannelMLImporter, self).__init__()
64
+ super().__init__()
75
65
  self.generated_name_index = 0
76
66
 
77
67
  def component(self, path, model):
@@ -147,7 +137,7 @@ class ChannelMLImporter(formats.Importer):
147
137
  ' supported.')
148
138
 
149
139
  # Add channel component
150
- name = self._sanitise_name(root.getAttribute('name'))
140
+ name = self._sanitize_name(root.getAttribute('name'))
151
141
  if name in model:
152
142
  name_root = name
153
143
  i = 2
@@ -200,7 +190,7 @@ class ChannelMLImporter(formats.Importer):
200
190
  # Add gates
201
191
  gvars = []
202
192
  for gate in cvr.getElementsByTagName('gate'):
203
- gname = self._sanitise_name(gate.getAttribute('name'))
193
+ gname = self._sanitize_name(gate.getAttribute('name'))
204
194
  gvar = component.add_variable(gname)
205
195
  gvar.promote(0)
206
196
  cstate = gate.getElementsByTagName('closed_state')
@@ -242,7 +232,7 @@ class ChannelMLImporter(formats.Importer):
242
232
  + gname + '>')
243
233
 
244
234
  # Add closed-to-open transition
245
- tname = self._sanitise_name(tco.getAttribute('name'))
235
+ tname = self._sanitize_name(tco.getAttribute('name'))
246
236
  tcovar = gvar.add_variable(tname)
247
237
  expr = str(tco.getAttribute('expr'))
248
238
  try:
@@ -255,7 +245,7 @@ class ChannelMLImporter(formats.Importer):
255
245
  tcovar.meta['expression'] = str(expr)
256
246
 
257
247
  # Add open-to-closed transition
258
- tname = self._sanitise_name(toc.getAttribute('name'))
248
+ tname = self._sanitize_name(toc.getAttribute('name'))
259
249
  tocvar = gvar.add_variable(tname)
260
250
  expr = str(toc.getAttribute('expr'))
261
251
  try:
@@ -284,7 +274,7 @@ class ChannelMLImporter(formats.Importer):
284
274
  tc = tc[0]
285
275
 
286
276
  # Add steady-state variable
287
- ssname = self._sanitise_name(ss.getAttribute('name'))
277
+ ssname = self._sanitize_name(ss.getAttribute('name'))
288
278
  ssvar = gvar.add_variable(ssname)
289
279
  expr = str(ss.getAttribute('expr'))
290
280
  try:
@@ -296,7 +286,7 @@ class ChannelMLImporter(formats.Importer):
296
286
  ssvar.meta['expression'] = str(expr)
297
287
 
298
288
  # Add time course variable
299
- tcname = self._sanitise_name(tc.getAttribute('name'))
289
+ tcname = self._sanitize_name(tc.getAttribute('name'))
300
290
  tcvar = gvar.add_variable(tcname)
301
291
  expr = str(tc.getAttribute('expr'))
302
292
  try:
@@ -373,7 +363,7 @@ class ChannelMLImporter(formats.Importer):
373
363
  if not root.hasAttribute('xmlns:meta'):
374
364
  return None
375
365
  ns = root.getAttribute('xmlns:meta')
376
- b = StringIO()
366
+ b = io.StringIO()
377
367
 
378
368
  def scan(parent):
379
369
  kid = dom_child(parent)
@@ -412,7 +402,7 @@ class ChannelMLImporter(formats.Importer):
412
402
  return textwrap.fill(
413
403
  str('\n'.join(text(node))), 70, replace_whitespace=False)
414
404
 
415
- def _sanitise_name(self, name):
405
+ def _sanitize_name(self, name):
416
406
  """
417
407
  Tests if a name is a valid myokit name. Adapts it if it isn't.
418
408
  """
@@ -4,10 +4,8 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import myokit.formats.ansic
8
+
11
9
  from ._ewriter import CppExpressionWriter
12
10
 
13
11
 
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  from myokit.formats.ansic import AnsiCExpressionWriter
11
8
 
12
9