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.
Files changed (200) hide show
  1. myokit/__init__.py +5 -23
  2. myokit/__main__.py +70 -117
  3. myokit/_aux.py +5 -8
  4. myokit/_config.py +22 -31
  5. myokit/_datablock.py +26 -70
  6. myokit/_datalog.py +23 -53
  7. myokit/_err.py +13 -15
  8. myokit/_expressions.py +35 -55
  9. myokit/_io.py +5 -22
  10. myokit/_model_api.py +34 -47
  11. myokit/_myokit_version.py +1 -5
  12. myokit/_parsing.py +17 -25
  13. myokit/_progress.py +4 -7
  14. myokit/_protocol.py +6 -9
  15. myokit/_sim/__init__.py +7 -24
  16. myokit/_sim/cable.c +1 -3
  17. myokit/_sim/cable.py +3 -5
  18. myokit/_sim/cmodel.h +1 -3
  19. myokit/_sim/cmodel.py +1 -4
  20. myokit/_sim/compiler.py +1 -4
  21. myokit/_sim/cvodessim.c +1 -4
  22. myokit/_sim/cvodessim.py +1 -4
  23. myokit/_sim/fiber_tissue.c +2 -6
  24. myokit/_sim/fiber_tissue.py +3 -5
  25. myokit/_sim/jacobian.py +6 -7
  26. myokit/_sim/mcl.h +51 -53
  27. myokit/_sim/opencl.py +9 -22
  28. myokit/_sim/openclsim.c +2 -6
  29. myokit/_sim/openclsim.py +6 -6
  30. myokit/_sim/pacing.h +2 -6
  31. myokit/_sim/rhs.c +3 -10
  32. myokit/_sim/rhs.py +4 -13
  33. myokit/_sim/sundials.py +1 -4
  34. myokit/_system.py +10 -16
  35. myokit/_unit.py +3 -12
  36. myokit/float.py +0 -3
  37. myokit/formats/__init__.py +8 -10
  38. myokit/formats/ansic/__init__.py +0 -3
  39. myokit/formats/ansic/_ewriter.py +2 -4
  40. myokit/formats/ansic/_exporter.py +0 -3
  41. myokit/formats/axon/__init__.py +1 -3
  42. myokit/formats/axon/_abf.py +12 -15
  43. myokit/formats/axon/_atf.py +5 -6
  44. myokit/formats/axon/_importer.py +0 -3
  45. myokit/formats/cellml/__init__.py +0 -3
  46. myokit/formats/cellml/_ewriter.py +3 -6
  47. myokit/formats/cellml/_exporter.py +3 -6
  48. myokit/formats/cellml/_importer.py +1 -4
  49. myokit/formats/cellml/v1/__init__.py +0 -4
  50. myokit/formats/cellml/v1/_api.py +7 -10
  51. myokit/formats/cellml/v1/_parser.py +2 -5
  52. myokit/formats/cellml/v1/_writer.py +2 -11
  53. myokit/formats/cellml/v2/__init__.py +0 -3
  54. myokit/formats/cellml/v2/_api.py +7 -16
  55. myokit/formats/cellml/v2/_parser.py +2 -5
  56. myokit/formats/cellml/v2/_writer.py +1 -4
  57. myokit/formats/channelml/__init__.py +0 -3
  58. myokit/formats/channelml/_importer.py +4 -14
  59. myokit/formats/cpp/__init__.py +1 -3
  60. myokit/formats/cpp/_ewriter.py +0 -3
  61. myokit/formats/cuda/__init__.py +0 -3
  62. myokit/formats/cuda/_ewriter.py +2 -4
  63. myokit/formats/cuda/_exporter.py +0 -3
  64. myokit/formats/easyml/__init__.py +0 -3
  65. myokit/formats/easyml/_ewriter.py +9 -11
  66. myokit/formats/easyml/_exporter.py +0 -3
  67. myokit/formats/html/__init__.py +0 -3
  68. myokit/formats/html/_exporter.py +0 -3
  69. myokit/formats/html/_flatten.py +5 -21
  70. myokit/formats/latex/__init__.py +0 -3
  71. myokit/formats/latex/_ewriter.py +1 -4
  72. myokit/formats/latex/_exporter.py +3 -5
  73. myokit/formats/mathml/__init__.py +0 -3
  74. myokit/formats/mathml/_ewriter.py +2 -11
  75. myokit/formats/mathml/_parser.py +3 -5
  76. myokit/formats/matlab/__init__.py +0 -3
  77. myokit/formats/matlab/_ewriter.py +1 -4
  78. myokit/formats/matlab/_exporter.py +0 -3
  79. myokit/formats/opencl/__init__.py +0 -3
  80. myokit/formats/opencl/_ewriter.py +2 -4
  81. myokit/formats/opencl/_exporter.py +0 -3
  82. myokit/formats/python/__init__.py +0 -3
  83. myokit/formats/python/_ewriter.py +2 -5
  84. myokit/formats/python/_exporter.py +0 -3
  85. myokit/formats/python/template/sim.py +10 -10
  86. myokit/formats/sbml/__init__.py +0 -3
  87. myokit/formats/sbml/_api.py +17 -11
  88. myokit/formats/sbml/_importer.py +1 -4
  89. myokit/formats/sbml/_parser.py +2 -5
  90. myokit/formats/stan/__init__.py +0 -3
  91. myokit/formats/stan/_ewriter.py +2 -4
  92. myokit/formats/stan/_exporter.py +1 -4
  93. myokit/formats/sympy/__init__.py +0 -3
  94. myokit/formats/sympy/_ereader.py +1 -4
  95. myokit/formats/sympy/_ewriter.py +2 -5
  96. myokit/formats/wcp/__init__.py +0 -3
  97. myokit/formats/wcp/_wcp.py +1 -7
  98. myokit/formats/xml/__init__.py +0 -3
  99. myokit/formats/xml/_exporter.py +0 -3
  100. myokit/formats/xml/_split.py +0 -3
  101. myokit/gui/__init__.py +75 -247
  102. myokit/gui/datablock_viewer.py +100 -83
  103. myokit/gui/datalog_viewer.py +32 -44
  104. myokit/gui/explorer.py +15 -21
  105. myokit/gui/ide.py +105 -125
  106. myokit/gui/progress.py +9 -9
  107. myokit/gui/source.py +405 -374
  108. myokit/gui/vargrapher.py +2 -12
  109. myokit/lib/deps.py +7 -8
  110. myokit/lib/guess.py +1 -2
  111. myokit/lib/hh.py +5 -7
  112. myokit/lib/markov.py +9 -11
  113. myokit/lib/multi.py +1 -3
  114. myokit/lib/plots.py +1 -3
  115. myokit/pacing.py +0 -3
  116. myokit/pype.py +7 -18
  117. myokit/tests/__init__.py +3 -6
  118. myokit/tests/ansic_event_based_pacing.py +1 -4
  119. myokit/tests/ansic_fixed_form_pacing.py +1 -4
  120. myokit/tests/test_aux.py +9 -23
  121. myokit/tests/test_cellml_v1_api.py +1 -16
  122. myokit/tests/test_cellml_v1_parser.py +0 -15
  123. myokit/tests/test_cellml_v1_writer.py +0 -9
  124. myokit/tests/test_cellml_v2_api.py +1 -16
  125. myokit/tests/test_cellml_v2_parser.py +0 -15
  126. myokit/tests/test_cellml_v2_writer.py +0 -9
  127. myokit/tests/test_cmodel.py +0 -9
  128. myokit/tests/test_compiler_detection.py +1 -11
  129. myokit/tests/test_component.py +0 -10
  130. myokit/tests/test_config.py +33 -66
  131. myokit/tests/test_datablock.py +1 -9
  132. myokit/tests/test_datalog.py +4 -21
  133. myokit/tests/test_dependency_checking.py +8 -23
  134. myokit/tests/test_expressions.py +0 -9
  135. myokit/tests/test_float.py +1 -5
  136. myokit/tests/test_formats.py +0 -9
  137. myokit/tests/test_formats_axon.py +1 -9
  138. myokit/tests/test_formats_cellml.py +0 -15
  139. myokit/tests/test_formats_channelml.py +0 -15
  140. myokit/tests/test_formats_easyml.py +0 -14
  141. myokit/tests/test_formats_exporters.py +1 -16
  142. myokit/tests/test_formats_expression_writers.py +1 -17
  143. myokit/tests/test_formats_html.py +0 -3
  144. myokit/tests/test_formats_importers.py +1 -16
  145. myokit/tests/test_formats_mathml_content.py +0 -9
  146. myokit/tests/test_formats_mathml_presentation.py +0 -9
  147. myokit/tests/test_formats_opencl.py +0 -10
  148. myokit/tests/test_formats_sbml.py +0 -15
  149. myokit/tests/test_formats_sympy.py +0 -9
  150. myokit/tests/test_formats_wcp.py +1 -3
  151. myokit/tests/test_io.py +6 -14
  152. myokit/tests/test_jacobian_calculator.py +1 -9
  153. myokit/tests/test_jacobian_tracer.py +0 -9
  154. myokit/tests/test_lib_deps.py +0 -9
  155. myokit/tests/test_lib_guess.py +0 -9
  156. myokit/tests/test_lib_hh.py +1 -9
  157. myokit/tests/test_lib_markov.py +1 -9
  158. myokit/tests/test_lib_multi.py +0 -9
  159. myokit/tests/test_lib_plots.py +0 -3
  160. myokit/tests/test_meta.py +0 -3
  161. myokit/tests/test_model.py +0 -10
  162. myokit/tests/test_model_building.py +2 -17
  163. myokit/tests/test_opencl_info.py +5 -14
  164. myokit/tests/test_pacing_factory.py +0 -3
  165. myokit/tests/test_pacing_system_c.py +0 -9
  166. myokit/tests/test_pacing_system_py.py +0 -9
  167. myokit/tests/test_parsing.py +5 -20
  168. myokit/tests/test_progress_reporters.py +0 -3
  169. myokit/tests/test_protocol.py +0 -9
  170. myokit/tests/test_protocol_floating_point.py +0 -9
  171. myokit/tests/test_protocol_time_series.py +0 -10
  172. myokit/tests/test_pype.py +0 -9
  173. myokit/tests/test_quantity.py +0 -9
  174. myokit/tests/test_rhs_benchmarker.py +1 -9
  175. myokit/tests/test_sbml_api.py +0 -15
  176. myokit/tests/test_sbml_parser.py +0 -15
  177. myokit/tests/test_simulation_1d.py +1 -10
  178. myokit/tests/test_simulation_cvodes.py +8 -16
  179. myokit/tests/test_simulation_cvodes_from_disk.py +0 -3
  180. myokit/tests/test_simulation_fiber_tissue.py +1 -10
  181. myokit/tests/test_simulation_log_interval.py +0 -9
  182. myokit/tests/test_simulation_opencl.py +1 -10
  183. myokit/tests/test_simulation_opencl_log_interval.py +1 -3
  184. myokit/tests/test_simulation_opencl_vs_cvode.py +1 -10
  185. myokit/tests/test_simulation_opencl_vs_sim1d.py +1 -10
  186. myokit/tests/test_system_info.py +1 -11
  187. myokit/tests/test_tools.py +0 -9
  188. myokit/tests/test_unit.py +0 -9
  189. myokit/tests/test_user_functions.py +0 -10
  190. myokit/tests/test_variable.py +0 -10
  191. myokit/tools.py +5 -21
  192. myokit/units.py +0 -3
  193. {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/METADATA +7 -7
  194. {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/RECORD +198 -200
  195. myokit/_exec_new.py +0 -15
  196. myokit/_exec_old.py +0 -15
  197. {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/LICENSE.txt +0 -0
  198. {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/WHEEL +0 -0
  199. {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/entry_points.txt +0 -0
  200. {myokit-1.34.0.dist-info → myokit-1.35.0.dist-info}/top_level.txt +0 -0
myokit/_parsing.py CHANGED
@@ -4,22 +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 os
11
8
  import re
12
- #import unicodedata
9
+
13
10
  from collections import OrderedDict
14
11
 
15
12
  import myokit
16
- from myokit import ParseError, ProtocolParseError
17
13
 
18
- # Strings in Python2 and Python3
19
- try:
20
- basestring
21
- except NameError: # pragma: no cover
22
- basestring = str
14
+ from myokit import ParseError, ProtocolParseError
23
15
 
24
16
 
25
17
  def parse(source):
@@ -34,7 +26,7 @@ def parse(source):
34
26
  """
35
27
  # Get raw stream
36
28
  raw = source
37
- if isinstance(raw, basestring):
29
+ if isinstance(raw, str):
38
30
  raw = raw.splitlines()
39
31
  raw = iter(raw)
40
32
 
@@ -78,7 +70,7 @@ def parse_model(source):
78
70
  """
79
71
  # Get raw stream
80
72
  raw = source
81
- if isinstance(raw, basestring):
73
+ if isinstance(raw, str):
82
74
  raw = raw.splitlines()
83
75
  raw = iter(raw)
84
76
 
@@ -100,7 +92,7 @@ def parse_protocol(source):
100
92
  """
101
93
  # Get raw stream
102
94
  raw = source
103
- if isinstance(raw, basestring):
95
+ if isinstance(raw, str):
104
96
  raw = raw.splitlines()
105
97
  raw = iter(raw)
106
98
 
@@ -122,7 +114,7 @@ def parse_script(source):
122
114
  """
123
115
  # Get raw stream
124
116
  raw = source
125
- if isinstance(raw, basestring):
117
+ if isinstance(raw, str):
126
118
  raw = raw.splitlines()
127
119
  raw = iter(raw)
128
120
 
@@ -162,7 +154,7 @@ def parse_state(state):
162
154
  """
163
155
  # Get raw stream
164
156
  raw = state
165
- if isinstance(raw, basestring):
157
+ if isinstance(raw, str):
166
158
  raw = raw.splitlines()
167
159
  raw = iter(raw)
168
160
 
@@ -205,7 +197,7 @@ def split(source):
205
197
  """
206
198
  # Get raw stream
207
199
  raw = source
208
- if isinstance(raw, basestring):
200
+ if isinstance(raw, str):
209
201
  raw = raw.splitlines()
210
202
  raw = iter(raw)
211
203
  segments = ['', '', '']
@@ -317,7 +309,7 @@ def unexpected_token(token, expected):
317
309
  # Parse expected token(s) or string
318
310
  if type(expected) == int:
319
311
  expected = [expected]
320
- if not isinstance(expected, basestring):
312
+ if not isinstance(expected, str):
321
313
  if len(expected) > 2:
322
314
  expected = 'one of [' \
323
315
  + ', '.join([token_str[i] for i in expected]) + ']'
@@ -348,7 +340,7 @@ def reg_token(info, token, obj):
348
340
  d[token[3]] = (token, obj)
349
341
 
350
342
 
351
- class ParseInfo(object):
343
+ class ParseInfo:
352
344
  def __init__(self):
353
345
  self.model = None
354
346
  self.initial_values = OrderedDict()
@@ -1071,7 +1063,7 @@ def strip_expression_units(model_text, skip_literals=True):
1071
1063
  This method will raise a :class:`myokit.ParseError` if the given code
1072
1064
  cannot be parsed to a valid model.
1073
1065
  """
1074
- if isinstance(model_text, basestring):
1066
+ if isinstance(model_text, str):
1075
1067
  lines = model_text.splitlines()
1076
1068
  else:
1077
1069
  lines = model_text
@@ -1267,7 +1259,7 @@ _COMPEQ = '=!><'
1267
1259
  _COMPEQ_MAP = [EQEQUAL, NOTEQUAL, MOREEQUAL, LESSEQUAL]
1268
1260
 
1269
1261
 
1270
- class Tokenizer(object):
1262
+ class Tokenizer:
1271
1263
  """
1272
1264
  Takes a stream of lines as input and provides a stream interface returning
1273
1265
  tokens.
@@ -1312,7 +1304,7 @@ class Tokenizer(object):
1312
1304
  self._catcheri = 0
1313
1305
 
1314
1306
  # String given instead of stream of lines? Convert
1315
- if isinstance(stream_of_lines, basestring):
1307
+ if isinstance(stream_of_lines, str):
1316
1308
  stream_of_lines = iter(stream_of_lines.splitlines())
1317
1309
 
1318
1310
  # Create tokenizer
@@ -1965,7 +1957,7 @@ def format_parse_error(ex, source=None):
1965
1957
  line = None
1966
1958
 
1967
1959
  if ex.line > 0 and source is not None:
1968
- if isinstance(source, basestring) and os.path.isfile(source):
1960
+ if isinstance(source, str) and os.path.isfile(source):
1969
1961
  # Re-open file, find line
1970
1962
  with open(source, 'r') as f:
1971
1963
  for i in range(0, ex.line):
@@ -2015,7 +2007,7 @@ def format_parse_error(ex, source=None):
2015
2007
  return '\n'.join(out)
2016
2008
 
2017
2009
 
2018
- class NudParser(object):
2010
+ class NudParser:
2019
2011
  """
2020
2012
  Expression parser for nud operators.
2021
2013
 
@@ -2084,7 +2076,7 @@ class FunctionParser(NudParser):
2084
2076
  Parser for function calls.
2085
2077
  """
2086
2078
  def __init__(self):
2087
- super(FunctionParser, self).__init__()
2079
+ super().__init__()
2088
2080
  self._rbp = myokit.Function._rbp
2089
2081
 
2090
2082
  def parse(self, stream, info):
@@ -2125,7 +2117,7 @@ class FunctionParser(NudParser):
2125
2117
  return (func, ops, (name,))
2126
2118
 
2127
2119
 
2128
- class LedParser(object):
2120
+ class LedParser:
2129
2121
  """
2130
2122
  Expression parser for led operators.
2131
2123
 
myokit/_progress.py CHANGED
@@ -4,15 +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 timeit
11
8
 
12
9
  import myokit
13
10
 
14
11
 
15
- class ProgressReporter(object):
12
+ class ProgressReporter:
16
13
  """
17
14
  Interface for progress updates in Simulations. Also allows some job types
18
15
  to be cancelled by the user.
@@ -62,7 +59,7 @@ class ProgressReporter(object):
62
59
  """
63
60
  pass
64
61
 
65
- class _Job(object):
62
+ class _Job:
66
63
  def __init__(self, parent, msg):
67
64
  self._parent = parent
68
65
  self._msg = msg
@@ -97,7 +94,7 @@ class ProgressPrinter(ProgressReporter):
97
94
  status every ten percent.
98
95
  """
99
96
  def __init__(self, digits=1):
100
- super(ProgressPrinter, self).__init__()
97
+ super().__init__()
101
98
  self._b = myokit.tools.Benchmarker()
102
99
  self._f = None
103
100
  self._d = int(digits)
@@ -138,7 +135,7 @@ class Timeout(ProgressReporter):
138
135
  Progress reporter that cancels a simulation after ``timeout`` seconds.
139
136
  """
140
137
  def __init__(self, timeout):
141
- super(Timeout, self).__init__()
138
+ super().__init__()
142
139
  self._timeout = float(timeout)
143
140
 
144
141
  def enter(self, msg=None):
myokit/_protocol.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
  import numpy as np
@@ -14,7 +11,7 @@ import numpy as np
14
11
  from bisect import bisect_right
15
12
 
16
13
 
17
- class Protocol(object):
14
+ class Protocol:
18
15
  """
19
16
  Represents a pacing protocol as a sequence of :class:`events
20
17
  <ProtocolEvent>`.
@@ -49,7 +46,7 @@ class Protocol(object):
49
46
  ``pickle``.
50
47
  """
51
48
  def __init__(self):
52
- super(Protocol, self).__init__()
49
+ super().__init__()
53
50
  self._head = None
54
51
 
55
52
  def add(self, e):
@@ -536,7 +533,7 @@ class Protocol(object):
536
533
  return [p.advance(t) for t in times]
537
534
 
538
535
 
539
- class ProtocolEvent(object):
536
+ class ProtocolEvent:
540
537
  """
541
538
  Describes an event occurring as part of a protocol.
542
539
  """
@@ -719,7 +716,7 @@ class ProtocolEvent(object):
719
716
  return self.in_words()
720
717
 
721
718
 
722
- class PacingSystem(object):
719
+ class PacingSystem:
723
720
  """
724
721
  This class uses a :class:`myokit.Protocol` to update the value of a
725
722
  pacing variable over time.
@@ -853,7 +850,7 @@ class NotAnUnbrokenSequenceError(myokit.MyokitError):
853
850
  pass
854
851
 
855
852
 
856
- class TimeSeriesProtocol(object):
853
+ class TimeSeriesProtocol:
857
854
  """
858
855
  Represents a pacing protocol as a sequence of time value pairs and an
859
856
  interpolation method (currently only linear interpolation is supported).
@@ -870,7 +867,7 @@ class TimeSeriesProtocol(object):
870
867
  """
871
868
 
872
869
  def __init__(self, times, values, method=None):
873
- super(TimeSeriesProtocol, self).__init__()
870
+ super().__init__()
874
871
 
875
872
  if len(times) != len(values):
876
873
  raise ValueError('Times and values array must have same size.')
myokit/_sim/__init__.py CHANGED
@@ -5,10 +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
- # Library imports
12
8
  import os
13
9
  import platform
14
10
  import sys
@@ -36,36 +32,23 @@ if platform.system() == 'Windows': # pragma: no linux cover
36
32
  ).stdin
37
33
  os.popen = _ospop
38
34
 
39
-
40
- # Setuptools imports
41
35
  from setuptools import setup, Extension # noqa
42
36
 
43
-
44
- # Myokit imports
45
37
  import myokit # noqa
46
38
  import myokit.pype # noqa
47
39
 
48
40
 
49
- # Dynamic module finding and loading in Python 3.5+ and younger
50
- if sys.hexversion >= 0x03050000:
51
- import importlib.machinery
41
+ def load_module(name, path):
42
+ """ Dynamically find and load a module (Python 3.5+). """
52
43
  import importlib
44
+ import importlib.machinery
53
45
 
54
- def load_module(name, path):
55
- spec = importlib.machinery.PathFinder.find_spec(name, [path])
56
- module = importlib.util.module_from_spec(spec)
57
- return module
58
-
59
- else: # pragma: no python 3 cover
60
- import imp
61
-
62
- def load_module(name, path):
63
- (f, pathname, description) = imp.find_module(name, [path])
64
- f.close()
65
- return imp.load_dynamic(name, pathname)
46
+ spec = importlib.machinery.PathFinder.find_spec(name, [path])
47
+ module = importlib.util.module_from_spec(spec)
48
+ return module
66
49
 
67
50
 
68
- class CModule(object):
51
+ class CModule:
69
52
  """
70
53
  Abstract base class for classes that dynamically create and compile a
71
54
  back-end C-module.
myokit/_sim/cable.c CHANGED
@@ -367,9 +367,7 @@ sim_init(PyObject *self, PyObject *args)
367
367
  for(i_state=0; i_state<ncells * N_STATE; i_state++) {
368
368
  flt = PyList_GetItem(state_in, i_state); /* Borrowed reference */
369
369
  if (!PyFloat_Check(flt)) {
370
- char errstr[200];
371
- sprintf(errstr, "Item %d in state vector is not a float.", i_state);
372
- PyErr_SetString(PyExc_Exception, errstr);
370
+ PyErr_Format(PyExc_Exception, "Item %d in state vector is not a float.", i_state);
373
371
  return sim_clean();
374
372
  }
375
373
  }
myokit/_sim/cable.py CHANGED
@@ -4,13 +4,11 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import os
11
- import myokit
12
8
  import platform
13
9
 
10
+ import myokit
11
+
14
12
  # Location of source file
15
13
  SOURCE_FILE = 'cable.c'
16
14
 
@@ -101,7 +99,7 @@ class Simulation1d(myokit.CModule):
101
99
  _index = 0 # Unique id for generated module
102
100
 
103
101
  def __init__(self, model, protocol=None, ncells=50, rl=False):
104
- super(Simulation1d, self).__init__()
102
+ super().__init__()
105
103
 
106
104
  # Require a valid model
107
105
  model.validate()
myokit/_sim/cmodel.h CHANGED
@@ -918,9 +918,7 @@ for eqs in s_output_equations:
918
918
  * Private method: Add a variable to the logging lists. Returns 1 if
919
919
  * successful.
920
920
  *
921
- * Note: The variable names are all ascii compatible. In Python2, the strings
922
- * inside log_dict are either unicode or bytes, but they can be matched
923
- * without conversion.
921
+ * Note: The variable names are all ascii compatible.
924
922
  *
925
923
  * Arguments
926
924
  * log_dict : A dictionary mapping variable names to sequences.
myokit/_sim/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 traceback
13
10
 
@@ -21,7 +18,7 @@ import myokit.pype
21
18
  SOURCE_FILE = 'cmodel.h'
22
19
 
23
20
 
24
- class CModel(object):
21
+ class CModel:
25
22
  """
26
23
  Generates ansi-C code for a model.
27
24
 
myokit/_sim/compiler.py CHANGED
@@ -4,9 +4,6 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import os
11
8
 
12
9
  import myokit
@@ -32,7 +29,7 @@ class Compiler(myokit.CModule):
32
29
  _compiler = None
33
30
 
34
31
  def __init__(self):
35
- super(Compiler, self).__init__()
32
+ super().__init__()
36
33
  # Create and cache back-end
37
34
  Compiler._index += 1
38
35
 
myokit/_sim/cvodessim.c CHANGED
@@ -173,11 +173,8 @@ void
173
173
  ErrorHandler(int error_code, const char *module, const char *function,
174
174
  char *msg, void *eh_data)
175
175
  {
176
- char errstr[1024];
177
176
  if (error_code > 0) {
178
- sprintf(errstr, "CVODES: %s", msg);
179
- PyErr_WarnEx(PyExc_RuntimeWarning, errstr, 1);
180
- /* Python 3.2+: PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "CVODES: %s", msg); */
177
+ PyErr_WarnFormat(PyExc_RuntimeWarning, 1, "CVODES: %s", msg);
181
178
  }
182
179
  }
183
180
 
myokit/_sim/cvodessim.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 platform
13
10
  import tempfile
@@ -152,7 +149,7 @@ class Simulation(myokit.CModule):
152
149
  _index = 0 # Simulation id
153
150
 
154
151
  def __init__(self, model, protocol=None, sensitivities=None, path=None):
155
- super(Simulation, self).__init__()
152
+ super().__init__()
156
153
 
157
154
  # Require a valid model
158
155
  if not model.is_valid():
@@ -542,9 +542,7 @@ sim_init(PyObject* self, PyObject* args)
542
542
  for(i=0; i < nfx * nfy * n_state_f; i++) {
543
543
  flt = PyList_GetItem(state_in_f, i); // Don't decref!
544
544
  if(!PyFloat_Check(flt)) {
545
- char errstr[200];
546
- sprintf(errstr, "Item %u in fiber state vector is not a float.", (unsigned int)i);
547
- PyErr_SetString(PyExc_Exception, errstr);
545
+ PyErr_Format(PyExc_Exception, "Item %u in fiber state vector is not a float.", (unsigned int)i);
548
546
  return sim_clean();
549
547
  }
550
548
  rvec_state_f[i] = (Real)PyFloat_AsDouble(flt);
@@ -558,9 +556,7 @@ sim_init(PyObject* self, PyObject* args)
558
556
  for(i=0; i < ntx * nty * n_state_t; i++) {
559
557
  flt = PyList_GetItem(state_in_t, i);
560
558
  if(!PyFloat_Check(flt)) {
561
- char errstr[200];
562
- sprintf(errstr, "Item %u in tissue state vector is not a float.", (unsigned int)i);
563
- PyErr_SetString(PyExc_Exception, errstr);
559
+ PyErr_Format(PyExc_Exception, "Item %u in tissue state vector is not a float.", (unsigned int)i);
564
560
  return sim_clean();
565
561
  }
566
562
  rvec_state_t[i] = (Real)PyFloat_AsDouble(flt);
@@ -4,13 +4,11 @@
4
4
  # This file is part of Myokit.
5
5
  # See http://myokit.org for copyright, sharing, and licensing details.
6
6
  #
7
- from __future__ import absolute_import, division
8
- from __future__ import print_function, unicode_literals
9
-
10
7
  import os
11
- import myokit
12
8
  import platform
13
9
 
10
+ import myokit
11
+
14
12
  # Location of C and OpenCL sources
15
13
  SOURCE_FILE = 'fiber_tissue.c'
16
14
  KERNEL_FILE = 'openclsim.cl'
@@ -122,7 +120,7 @@ class FiberTissueSimulation(myokit.CModule):
122
120
  ncells_fiber=(128, 2), ncells_tissue=(128, 128), nx_paced=5,
123
121
  g_fiber=(9, 6), g_tissue=(9, 6), g_fiber_tissue=9,
124
122
  dt=0.005, precision=myokit.SINGLE_PRECISION, native_maths=False):
125
- super(FiberTissueSimulation, self).__init__()
123
+ super().__init__()
126
124
 
127
125
  # Deprecated since 2021-05-28
128
126
  # Un-deprecated on 2022-04-20, following Adam's request
myokit/_sim/jacobian.py CHANGED
@@ -4,14 +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
7
  import os
11
- import myokit
12
- import numpy as np
13
8
  import platform
14
9
 
10
+ import numpy as np
11
+
12
+ import myokit
13
+
15
14
  # Location of C source file
16
15
  SOURCE_FILE = 'jacobian.cpp'
17
16
 
@@ -45,7 +44,7 @@ class JacobianTracer(myokit.CppModule):
45
44
  _index = 0 # Unique id
46
45
 
47
46
  def __init__(self, model):
48
- super(JacobianTracer, self).__init__()
47
+ super().__init__()
49
48
 
50
49
  # Require a valid model
51
50
  model.validate()
@@ -216,7 +215,7 @@ class JacobianCalculator(myokit.CppModule):
216
215
  _index = 0 # Unique id
217
216
 
218
217
  def __init__(self, model):
219
- super(JacobianCalculator, self).__init__()
218
+ super().__init__()
220
219
  # Require a valid model
221
220
  model.validate()
222
221