bluecellulab 2.5.10__py3-none-any.whl → 2.6.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.

Potentially problematic release.


This version of bluecellulab might be problematic. Click here for more details.

bluecellulab/__init__.py CHANGED
@@ -7,7 +7,7 @@ try:
7
7
  except ImportError:
8
8
  BLUEPY_AVAILABLE = False
9
9
 
10
- from .importer import * # NOQA
10
+ from bluecellulab.importer import import_hoc
11
11
  from .verbosity import *
12
12
  from .cell import Cell, create_ball_stick # NOQA
13
13
  from .circuit import EmodelProperties
@@ -19,7 +19,7 @@ from .psegment import PSegment # NOQA
19
19
  from .simulation import Simulation # NOQA
20
20
  from .rngsettings import RNGSettings # NOQA
21
21
  from .circuit_simulation import CircuitSimulation, CircuitSimulation # NOQA
22
-
22
+ import neuron
23
23
 
24
24
  from .simulation.neuron_globals import NeuronGlobals
25
25
 
@@ -7,9 +7,9 @@ import neuron
7
7
  import numpy as np
8
8
  from bluecellulab.cell.core import Cell
9
9
  from bluecellulab.cell.template import TemplateParams
10
+ from bluecellulab.simulation.parallel import IsolatedProcess
10
11
  from bluecellulab.simulation.simulation import Simulation
11
12
  from bluecellulab.stimulus.factory import Stimulus, StimulusFactory
12
- from bluecellulab.utils import IsolatedProcess
13
13
 
14
14
 
15
15
  class StimulusName(Enum):
@@ -35,7 +35,6 @@ def run_stimulus(
35
35
  stimulus: Stimulus,
36
36
  section: str,
37
37
  segment: float,
38
- duration: float,
39
38
  ) -> Recording:
40
39
  """Creates a cell and stimulates it with a given stimulus.
41
40
 
@@ -44,7 +43,6 @@ def run_stimulus(
44
43
  stimulus: The input stimulus to inject into the cell.
45
44
  section: Name of the section of cell where the stimulus is to be injected.
46
45
  segment: The segment of the section where the stimulus is to be injected.
47
- duration: The duration for which the simulation is to be run.
48
46
 
49
47
  Returns:
50
48
  The voltage-time recording at the specified location.
@@ -61,7 +59,7 @@ def run_stimulus(
61
59
  current_vector = neuron.h.Vector()
62
60
  current_vector.record(iclamp._ref_i)
63
61
  simulation = Simulation(cell)
64
- simulation.run(duration)
62
+ simulation.run(stimulus.stimulus_time)
65
63
  current = np.array(current_vector.to_python())
66
64
  voltage = cell.get_voltage_recording(neuron_section, segment)
67
65
  time = cell.get_time()
@@ -74,7 +72,6 @@ def apply_multiple_step_stimuli(
74
72
  cell: Cell,
75
73
  stimulus_name: StimulusName,
76
74
  amplitudes: Sequence[float],
77
- duration: float,
78
75
  section_name: str | None = None,
79
76
  segment: float = 0.5,
80
77
  n_processes: int | None = None,
@@ -85,7 +82,6 @@ def apply_multiple_step_stimuli(
85
82
  cell: The cell to which the stimuli are applied.
86
83
  stimulus_name: The name of the stimulus to apply.
87
84
  amplitudes: The amplitudes of the stimuli to apply.
88
- duration: The duration for which each stimulus is applied.
89
85
  section_name: Section name of the cell where the stimuli are applied.
90
86
  If None, the stimuli are applied at the soma[0] of the cell.
91
87
  segment: The segment of the section where the stimuli are applied.
@@ -116,7 +112,7 @@ def apply_multiple_step_stimuli(
116
112
  else:
117
113
  raise ValueError("Unknown stimulus name.")
118
114
 
119
- task_args.append((cell.template_params, stimulus, section_name, segment, duration))
115
+ task_args.append((cell.template_params, stimulus, section_name, segment))
120
116
 
121
117
  with IsolatedProcess(processes=n_processes) as pool:
122
118
  # Map expects a function and a list of argument tuples
@@ -19,8 +19,9 @@ import os
19
19
  from pathlib import Path
20
20
  from typing import Optional
21
21
 
22
+ import neuron
22
23
  import pandas as pd
23
- from bluecellulab import circuit, neuron
24
+ from bluecellulab import circuit
24
25
  from bluecellulab.circuit.circuit_access import EmodelProperties
25
26
  from bluecellulab.circuit.config import BluepySimulationConfig
26
27
  from bluecellulab.circuit.config.definition import SimulationConfig
@@ -22,8 +22,9 @@ from bluepysnap.bbp import Cell as SnapCell
22
22
  from bluepysnap.circuit_ids import CircuitNodeId, CircuitEdgeIds
23
23
  from bluepysnap.exceptions import BluepySnapError
24
24
  from bluepysnap import Circuit as SnapCircuit
25
+ import neuron
25
26
  import pandas as pd
26
- from bluecellulab import circuit, neuron
27
+ from bluecellulab import circuit
27
28
  from bluecellulab.circuit.circuit_access.definition import EmodelProperties
28
29
  from bluecellulab.circuit import CellId, SynapseProperty
29
30
  from bluecellulab.circuit.config import SimulationConfig
@@ -13,6 +13,7 @@
13
13
  # limitations under the License.
14
14
  """Module that handles the global NEURON parameters."""
15
15
 
16
+ from typing import NamedTuple
16
17
  import neuron
17
18
  from bluecellulab.circuit.config.sections import Conditions, MechanismConditions
18
19
  from bluecellulab.exceptions import error_context
@@ -62,6 +63,11 @@ def set_minis_single_vesicle_values(mech_conditions: MechanismConditions) -> Non
62
63
  )
63
64
 
64
65
 
66
+ class NeuronGlobalParams(NamedTuple):
67
+ temperature: float
68
+ v_init: float
69
+
70
+
65
71
  class NeuronGlobals:
66
72
  _instance = None
67
73
 
@@ -96,3 +102,10 @@ class NeuronGlobals:
96
102
  def v_init(self, value):
97
103
  self._v_init = value
98
104
  neuron.h.v_init = value
105
+
106
+ def export_params(self) -> NeuronGlobalParams:
107
+ return NeuronGlobalParams(self.temperature, self.v_init)
108
+
109
+ def load_params(self, params: NeuronGlobalParams) -> None:
110
+ self.temperature = params.temperature
111
+ self.v_init = params.v_init
@@ -0,0 +1,36 @@
1
+ """Controlled simulations in parallel."""
2
+
3
+ from __future__ import annotations
4
+ from multiprocessing.pool import Pool
5
+ from bluecellulab.simulation.neuron_globals import NeuronGlobals
6
+
7
+
8
+ class IsolatedProcess(Pool):
9
+ """Multiprocessing Pool that restricts a worker to run max 1 process.
10
+
11
+ Use this when running isolated NEURON simulations. Running 2 NEURON
12
+ simulations on a single process is to be avoided. Required global
13
+ NEURON simulation parameters will automatically be passed to each
14
+ worker.
15
+ """
16
+
17
+ def __init__(self, processes: int | None = 1):
18
+ """Initialize the IsolatedProcess pool.
19
+
20
+ Args:
21
+ processes: The number of processes to use for running the simulations.
22
+ If set to None, then the number returned by os.cpu_count() is used.
23
+ """
24
+ neuron_global_params = NeuronGlobals.get_instance().export_params()
25
+ super().__init__(
26
+ processes=processes,
27
+ initializer=self.init_worker,
28
+ initargs=(neuron_global_params,),
29
+ maxtasksperchild=1,
30
+ )
31
+
32
+ @staticmethod
33
+ def init_worker(neuron_global_params):
34
+ """Load global parameters for the NEURON environment in each worker
35
+ process."""
36
+ NeuronGlobals.get_instance().load_params(neuron_global_params)
@@ -39,38 +39,38 @@ class Stimulus(ABC):
39
39
  ax.set_title(self.__class__.__name__)
40
40
  return ax
41
41
 
42
- def plot_during_simulation(self, duration: float, ax=None, **kwargs):
43
- if ax is None:
44
- ax = plt.gca()
45
- # Create an array for the entire duration
46
- full_time = np.arange(0, duration, self.dt)
47
- full_current = np.zeros_like(full_time)
48
-
49
- # Replace the corresponding values with self.time and self.current
50
- indices = (self.time / self.dt).astype(int)
51
- full_current[indices] = self.current
52
-
53
- ax.plot(full_time, full_current, **kwargs)
54
- ax.set_xlabel("Time (ms)")
55
- ax.set_ylabel("Current (nA)")
56
- ax.set_title(self.__class__.__name__)
57
- ax.set_xlim(0, duration)
58
- return ax
59
-
60
42
  def __add__(self, other: Stimulus) -> CombinedStimulus:
61
43
  """Override + operator to concatenate Stimulus objects."""
62
44
  if self.dt != other.dt:
63
- raise ValueError("Stimulus objects must have the same dt to be concatenated")
64
- # shift other time
65
- other_time = other.time + self.time[-1] + self.dt
66
- combined_time = np.concatenate([self.time, other_time])
67
- # Concatenate the current arrays
68
- combined_current = np.concatenate([self.current, other.current])
69
- return CombinedStimulus(self.dt, combined_time, combined_current)
45
+ raise ValueError(
46
+ "Stimulus objects must have the same dt to be concatenated"
47
+ )
48
+ if len(self.time) == 0:
49
+ return CombinedStimulus(other.dt, other.time, other.current)
50
+ elif len(other.time) == 0:
51
+ return CombinedStimulus(self.dt, self.time, self.current)
52
+ else:
53
+ # shift other time
54
+ other_time = other.time + self.time[-1] + self.dt
55
+ combined_time = np.concatenate([self.time, other_time])
56
+ # Concatenate the current arrays
57
+ combined_current = np.concatenate([self.current, other.current])
58
+ return CombinedStimulus(self.dt, combined_time, combined_current)
59
+
60
+ def __eq__(self, other: object) -> bool:
61
+ if not isinstance(other, Stimulus):
62
+ return NotImplemented
63
+ else:
64
+ return (
65
+ np.allclose(self.time, other.time)
66
+ and np.allclose(self.current, other.current)
67
+ and self.dt == other.dt
68
+ )
70
69
 
71
70
 
72
71
  class CombinedStimulus(Stimulus):
73
72
  """Represents the Stimulus created by combining multiple stimuli."""
73
+
74
74
  def __init__(self, dt: float, time: np.ndarray, current: np.ndarray) -> None:
75
75
  super().__init__(dt)
76
76
  self._time = time
@@ -85,11 +85,12 @@ class CombinedStimulus(Stimulus):
85
85
  return self._current
86
86
 
87
87
 
88
- class EmptyStimulus(Stimulus):
88
+ class Empty(Stimulus):
89
89
  """Represents empty stimulus (all zeros) that has no impact on the cell.
90
90
 
91
91
  This is required by some Stimuli that expect the cell to rest.
92
92
  """
93
+
93
94
  def __init__(self, dt: float, duration: float) -> None:
94
95
  super().__init__(dt)
95
96
  self.duration = duration
@@ -103,152 +104,286 @@ class EmptyStimulus(Stimulus):
103
104
  return np.zeros_like(self.time)
104
105
 
105
106
 
106
- class Step(Stimulus):
107
- def __init__(self, dt: float, start: float, end: float, amplitude: float) -> None:
107
+ class Flat(Stimulus):
108
+ def __init__(self, dt: float, duration: float, amplitude: float) -> None:
108
109
  super().__init__(dt)
109
- self.start = start
110
- self.end = end
110
+ self.duration = duration
111
111
  self.amplitude = amplitude
112
112
 
113
- @classmethod
114
- def threshold_based(
115
- cls,
116
- dt: float,
117
- threshold_current: float,
118
- threshold_percentage: float,
119
- start: float,
120
- end: float,
121
- post_wait: float,
122
- ) -> CombinedStimulus:
123
- amplitude = threshold_current * threshold_percentage / 100
124
- res = cls(dt, start, end, amplitude) + EmptyStimulus(dt, duration=post_wait)
125
- return res
126
-
127
113
  @property
128
114
  def time(self) -> np.ndarray:
129
- return np.arange(self.start, self.end, self.dt)
115
+ return np.arange(0.0, self.duration, self.dt)
130
116
 
131
117
  @property
132
118
  def current(self) -> np.ndarray:
133
119
  return np.full_like(self.time, self.amplitude)
134
120
 
135
121
 
136
- class Ramp(Stimulus):
122
+ class Slope(Stimulus):
137
123
  def __init__(
138
- self,
139
- dt: float,
140
- start: float,
141
- end: float,
142
- amplitude_start: float,
143
- amplitude_end: float,
124
+ self, dt: float, duration: float, amplitude_start: float, amplitude_end: float
144
125
  ) -> None:
145
126
  super().__init__(dt)
146
- self.start = start
147
- self.end = end
127
+ self.duration = duration
148
128
  self.amplitude_start = amplitude_start
149
129
  self.amplitude_end = amplitude_end
150
130
 
151
131
  @property
152
132
  def time(self) -> np.ndarray:
153
- return np.arange(self.start, self.end, self.dt)
133
+ return np.arange(0.0, self.duration, self.dt)
154
134
 
155
135
  @property
156
136
  def current(self) -> np.ndarray:
157
137
  return np.linspace(self.amplitude_start, self.amplitude_end, len(self.time))
158
138
 
159
139
 
140
+ class Step(Stimulus):
141
+
142
+ def __init__(self):
143
+ raise NotImplementedError(
144
+ "This class cannot be instantiated directly. "
145
+ "Please use the class methods 'amplitude_based' "
146
+ "or 'threshold_based' to create objects."
147
+ )
148
+
149
+ @classmethod
150
+ def amplitude_based(
151
+ cls,
152
+ dt: float,
153
+ pre_delay: float,
154
+ duration: float,
155
+ post_delay: float,
156
+ amplitude: float,
157
+ ) -> CombinedStimulus:
158
+ """Create a Step stimulus from given time events and amplitude.
159
+
160
+ Args:
161
+ dt: The time step of the stimulus.
162
+ pre_delay: The delay before the start of the step.
163
+ duration: The duration of the step.
164
+ post_delay: The time to wait after the end of the step.
165
+ amplitude: The amplitude of the step.
166
+ """
167
+ return (
168
+ Empty(dt, duration=pre_delay)
169
+ + Flat(dt, duration=duration, amplitude=amplitude)
170
+ + Empty(dt, duration=post_delay)
171
+ )
172
+
173
+ @classmethod
174
+ def threshold_based(
175
+ cls,
176
+ dt: float,
177
+ pre_delay: float,
178
+ duration: float,
179
+ post_delay: float,
180
+ threshold_current: float,
181
+ threshold_percentage: float,
182
+ ) -> CombinedStimulus:
183
+ """Creates a Step stimulus with respect to the threshold current.
184
+
185
+ Args:
186
+
187
+ dt: The time step of the stimulus.
188
+ pre_delay: The delay before the start of the step.
189
+ duration: The duration of the step.
190
+ post_delay: The time to wait after the end of the step.
191
+ threshold_current: The threshold current of the Cell.
192
+ threshold_percentage: Percentage of desired threshold_current amplification.
193
+ """
194
+ amplitude = threshold_current * threshold_percentage / 100
195
+ res = cls.amplitude_based(
196
+ dt,
197
+ pre_delay=pre_delay,
198
+ duration=duration,
199
+ post_delay=post_delay,
200
+ amplitude=amplitude,
201
+ )
202
+ return res
203
+
204
+
205
+ class Ramp(Stimulus):
206
+
207
+ def __init__(self):
208
+ raise NotImplementedError(
209
+ "This class cannot be instantiated directly. "
210
+ "Please use the class methods 'amplitude_based' "
211
+ "or 'threshold_based' to create objects."
212
+ )
213
+
214
+ @classmethod
215
+ def amplitude_based(
216
+ cls,
217
+ dt: float,
218
+ pre_delay: float,
219
+ duration: float,
220
+ post_delay: float,
221
+ amplitude: float,
222
+ ) -> CombinedStimulus:
223
+ """Create a Ramp stimulus from given time events and amplitudes.
224
+
225
+ Args:
226
+ dt: The time step of the stimulus.
227
+ pre_delay: The delay before the start of the ramp.
228
+ duration: The duration of the ramp.
229
+ post_delay: The time to wait after the end of the ramp.
230
+ amplitude: The final amplitude of the ramp.
231
+ """
232
+ return (
233
+ Empty(dt, duration=pre_delay)
234
+ + Slope(
235
+ dt,
236
+ duration=duration,
237
+ amplitude_start=0.0,
238
+ amplitude_end=amplitude,
239
+ )
240
+ + Empty(dt, duration=post_delay)
241
+ )
242
+
243
+ @classmethod
244
+ def threshold_based(
245
+ cls,
246
+ dt: float,
247
+ pre_delay: float,
248
+ duration: float,
249
+ post_delay: float,
250
+ threshold_current: float,
251
+ threshold_percentage: float,
252
+ ) -> CombinedStimulus:
253
+ """Creates a Ramp stimulus with respect to the threshold current.
254
+
255
+ Args:
256
+
257
+ dt: The time step of the stimulus.
258
+ pre_delay: The delay before the start of the ramp.
259
+ duration: The duration of the ramp.
260
+ post_delay: The time to wait after the end of the ramp.
261
+ threshold_current: The threshold current of the Cell.
262
+ threshold_percentage: Percentage of desired threshold_current amplification.
263
+ """
264
+ amplitude = threshold_current * threshold_percentage / 100
265
+ res = cls.amplitude_based(
266
+ dt,
267
+ pre_delay=pre_delay,
268
+ duration=duration,
269
+ post_delay=post_delay,
270
+ amplitude=amplitude,
271
+ )
272
+ return res
273
+
274
+
160
275
  class StimulusFactory:
161
276
  def __init__(self, dt: float):
162
277
  self.dt = dt
163
278
 
164
- def step(self, start: float, end: float, amplitude: float) -> Stimulus:
165
- return Step(self.dt, start, end, amplitude)
279
+ def step(
280
+ self, pre_delay: float, duration: float, post_delay: float, amplitude: float
281
+ ) -> Stimulus:
282
+ return Step.amplitude_based(
283
+ self.dt,
284
+ pre_delay=pre_delay,
285
+ duration=duration,
286
+ post_delay=post_delay,
287
+ amplitude=amplitude,
288
+ )
166
289
 
167
290
  def ramp(
168
- self, start: float, end: float, amplitude_start: float, amplitude_end: float
291
+ self, pre_delay: float, duration: float, post_delay: float, amplitude: float
169
292
  ) -> Stimulus:
170
- return Ramp(self.dt, start, end, amplitude_start, amplitude_end)
293
+ return Ramp.amplitude_based(
294
+ self.dt,
295
+ pre_delay=pre_delay,
296
+ duration=duration,
297
+ post_delay=post_delay,
298
+ amplitude=amplitude,
299
+ )
171
300
 
172
301
  def ap_waveform(
173
- self,
174
- threshold_current: float,
175
- threshold_percentage: float = 220.0,
176
- start: float = 250.0,
177
- end: float = 300.0,
178
- post_wait: float = 250.0,
302
+ self, threshold_current: float, threshold_percentage: float = 220.0
179
303
  ) -> Stimulus:
180
304
  """Returns the APWaveform Stimulus object, a type of Step stimulus.
181
305
 
182
306
  Args:
183
307
  threshold_current: The threshold current of the Cell.
184
308
  threshold_percentage: Percentage of desired threshold_current amplification.
185
- start: The start time of the step.
186
- end: The end time of the step.
187
- post_wait: The time to wait after the end of the step.
188
309
  """
310
+ pre_delay = 250.0
311
+ duration = 50.0
312
+ post_delay = 250.0
189
313
  return Step.threshold_based(
190
- self.dt, threshold_current, threshold_percentage, start, end, post_wait
314
+ self.dt,
315
+ pre_delay=pre_delay,
316
+ duration=duration,
317
+ post_delay=post_delay,
318
+ threshold_current=threshold_current,
319
+ threshold_percentage=threshold_percentage,
191
320
  )
192
321
 
193
322
  def idrest(
194
323
  self,
195
324
  threshold_current: float,
196
325
  threshold_percentage: float = 200.0,
197
- start: float = 250.0,
198
- end: float = 1600.0,
199
- post_wait: float = 250.0,
200
326
  ) -> Stimulus:
201
327
  """Returns the IDRest Stimulus object, a type of Step stimulus.
202
328
 
203
329
  Args:
204
330
  threshold_current: The threshold current of the Cell.
205
331
  threshold_percentage: Percentage of desired threshold_current amplification.
206
- start: The start time of the step.
207
- end: The end time of the step.
208
- post_wait: The time to wait after the end of the step.
209
332
  """
333
+ pre_delay = 250.0
334
+ duration = 1350.0
335
+ post_delay = 250.0
210
336
  return Step.threshold_based(
211
- self.dt, threshold_current, threshold_percentage, start, end, post_wait
337
+ self.dt,
338
+ pre_delay=pre_delay,
339
+ duration=duration,
340
+ post_delay=post_delay,
341
+ threshold_current=threshold_current,
342
+ threshold_percentage=threshold_percentage,
212
343
  )
213
344
 
214
345
  def iv(
215
346
  self,
216
347
  threshold_current: float,
217
348
  threshold_percentage: float = -40.0,
218
- start: float = 250.0,
219
- end: float = 3250.0,
220
- post_wait: float = 250.0,
221
349
  ) -> Stimulus:
222
350
  """Returns the IV Stimulus object, a type of Step stimulus.
223
351
 
224
352
  Args:
225
353
  threshold_current: The threshold current of the Cell.
226
354
  threshold_percentage: Percentage of desired threshold_current amplification.
227
- start: The start time of the step.
228
- end: The end time of the step.
229
- post_wait: The time to wait after the end of the step.
230
355
  """
356
+ pre_delay = 250.0
357
+ duration = 3000.0
358
+ post_delay = 250.0
231
359
  return Step.threshold_based(
232
- self.dt, threshold_current, threshold_percentage, start, end, post_wait
360
+ self.dt,
361
+ pre_delay=pre_delay,
362
+ duration=duration,
363
+ post_delay=post_delay,
364
+ threshold_current=threshold_current,
365
+ threshold_percentage=threshold_percentage,
233
366
  )
234
367
 
235
368
  def fire_pattern(
236
369
  self,
237
370
  threshold_current: float,
238
371
  threshold_percentage: float = 200.0,
239
- start: float = 250.0,
240
- end: float = 3850.0,
241
- post_wait: float = 250.0,
242
372
  ) -> Stimulus:
243
373
  """Returns the FirePattern Stimulus object, a type of Step stimulus.
244
374
 
245
375
  Args:
246
376
  threshold_current: The threshold current of the Cell.
247
377
  threshold_percentage: Percentage of desired threshold_current amplification.
248
- start: The start time of the step.
249
- end: The end time of the step.
250
- post_wait: The time to wait after the end of the step.
251
378
  """
379
+ pre_delay = 250.0
380
+ duration = 3600.0
381
+ post_delay = 250.0
252
382
  return Step.threshold_based(
253
- self.dt, threshold_current, threshold_percentage, start, end, post_wait
383
+ self.dt,
384
+ pre_delay=pre_delay,
385
+ duration=duration,
386
+ post_delay=post_delay,
387
+ threshold_current=threshold_current,
388
+ threshold_percentage=threshold_percentage,
254
389
  )
bluecellulab/tools.py CHANGED
@@ -25,7 +25,8 @@ import numpy as np
25
25
  import bluecellulab
26
26
  from bluecellulab.circuit.circuit_access import EmodelProperties
27
27
  from bluecellulab.exceptions import UnsteadyCellError
28
- from bluecellulab.utils import CaptureOutput, IsolatedProcess
28
+ from bluecellulab.simulation.parallel import IsolatedProcess
29
+ from bluecellulab.utils import CaptureOutput
29
30
 
30
31
  logger = logging.getLogger(__name__)
31
32
 
bluecellulab/utils.py CHANGED
@@ -1,19 +1,21 @@
1
1
  """Utility functions used within BlueCellulab."""
2
+
2
3
  from __future__ import annotations
3
4
  import contextlib
4
5
  import io
5
6
  import json
6
- from multiprocessing.pool import Pool
7
7
 
8
8
  import numpy as np
9
9
 
10
10
 
11
11
  def run_once(func):
12
12
  """A decorator to ensure a function is only called once."""
13
+
13
14
  def wrapper(*args, **kwargs):
14
15
  if not wrapper.has_run:
15
16
  wrapper.has_run = True
16
17
  return func(*args, **kwargs)
18
+
17
19
  wrapper.has_run = False
18
20
  return wrapper
19
21
 
@@ -32,29 +34,25 @@ class CaptureOutput(list):
32
34
 
33
35
  class NumpyEncoder(json.JSONEncoder):
34
36
  def default(self, obj):
35
- if isinstance(obj, (np.int_, np.intc, np.intp, np.int8,
36
- np.int16, np.int32, np.int64, np.uint8,
37
- np.uint16, np.uint32, np.uint64)):
37
+ if isinstance(
38
+ obj,
39
+ (
40
+ np.int_,
41
+ np.intc,
42
+ np.intp,
43
+ np.int8,
44
+ np.int16,
45
+ np.int32,
46
+ np.int64,
47
+ np.uint8,
48
+ np.uint16,
49
+ np.uint32,
50
+ np.uint64,
51
+ ),
52
+ ):
38
53
  return int(obj)
39
- elif isinstance(obj, (np.float_, np.float16, np.float32,
40
- np.float64)):
54
+ elif isinstance(obj, (np.float_, np.float16, np.float32, np.float64)):
41
55
  return float(obj)
42
56
  elif isinstance(obj, np.ndarray):
43
57
  return obj.tolist()
44
58
  return json.JSONEncoder.default(self, obj)
45
-
46
-
47
- class IsolatedProcess(Pool):
48
- """Multiprocessing Pool that restricts a worker to run max 1 process.
49
-
50
- Use this when running isolated NEURON simulations. Running 2 NEURON
51
- simulations on a single process is to be avoided.
52
- """
53
- def __init__(self, processes: int | None = 1):
54
- """Initialize the IsolatedProcess pool.
55
-
56
- Args:
57
- processes: The number of processes to use for running the stimuli.
58
- If set to None, then the number returned by os.cpu_count() is used.
59
- """
60
- super().__init__(processes=processes, maxtasksperchild=1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: bluecellulab
3
- Version: 2.5.10
3
+ Version: 2.6.0
4
4
  Summary: Biologically detailed neural network simulations and analysis.
5
5
  Author: Blue Brain Project, EPFL
6
6
  License: Apache2.0
@@ -1,4 +1,4 @@
1
- bluecellulab/__init__.py,sha256=-DopR1_1ji4NQlsRi4fLSUETM358o6UCdJtnhQ8wrQA,873
1
+ bluecellulab/__init__.py,sha256=JvigOm_7WDjVAodm4R_TyRzj7vd9hmEbvLJDUVtgeqo,899
2
2
  bluecellulab/circuit_simulation.py,sha256=GLy_O5onhiSa-RajorDHlgP1rkFxjUONB4G6B4upyg0,33672
3
3
  bluecellulab/connection.py,sha256=volV2YKtmqAF7MOEJar5ldF1ARAo7k2vF9MB1NXybUY,4640
4
4
  bluecellulab/dendrogram.py,sha256=w0vvv0Q169DolTX1j9dAZIvHIl4H258gAjQ1xQaNiGk,6427
@@ -10,12 +10,12 @@ bluecellulab/plotwindow.py,sha256=UVHzml-BB83m5Qr-YGkjR9kB-vSW8mM0Owh2j95yIaU,27
10
10
  bluecellulab/psection.py,sha256=SYI2mGUIp8UiuMkyp9ITChHVLbJ0fDsEmen1pAbgNJQ,6174
11
11
  bluecellulab/psegment.py,sha256=02DkvazPGjnwjfjn1K8CZqdcVWnUhYpgrjqjoHNz6jM,3133
12
12
  bluecellulab/rngsettings.py,sha256=Dlt34dc4AoWyxCCzUK3Jlui90VCK20xHg6gD_OJzPIw,4237
13
- bluecellulab/tools.py,sha256=JrAfMVozfucwcyGklweMvEM7uGnTnWIDmk4eqI-43Es,11169
13
+ bluecellulab/tools.py,sha256=Bg6F0allDJrQrvxfvPdMdFe47a_CF7Q-KmF2TWNDE44,11213
14
14
  bluecellulab/type_aliases.py,sha256=DvgjERv2Ztdw_sW63JrZTQGpJ0x5uMTFB5hcBHDb0WA,441
15
- bluecellulab/utils.py,sha256=fgqjgy3xzyL0zu-qjCPJdHp6PEAHADCzlr2FqyBmzHI,2012
15
+ bluecellulab/utils.py,sha256=SbOOkzw1YGjCKV3qOw0zpabNEy7V9BRtgMLsQJiFRq4,1526
16
16
  bluecellulab/verbosity.py,sha256=T0IgX7DrRo19faxrT4Xzb27gqxzoILQ8FzYKxvUeaPM,1342
17
17
  bluecellulab/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- bluecellulab/analysis/inject_sequence.py,sha256=jfEESRAUKAWgjceNWfx3Rwe1gDNWhxwZL4PfnJZCzrg,4930
18
+ bluecellulab/analysis/inject_sequence.py,sha256=qr3N1tQX4avvKzFBT0L7W6LnSgk2y_P_7Yhy0UjlGmk,4769
19
19
  bluecellulab/cell/__init__.py,sha256=Sbc0QOsJ8E7tSwf3q7fsXuE_SevBN6ZmoCVyyU5zfII,208
20
20
  bluecellulab/cell/cell_dict.py,sha256=PVmZsjhZ9jp3HC-8QmdFqp-crAcVMSVeLWujcOPLlpo,1346
21
21
  bluecellulab/cell/core.py,sha256=MtrVQAxT82dc9uQuWZyTQfc6Oczrnc_y_9hcyBqUT7w,31467
@@ -39,9 +39,9 @@ bluecellulab/circuit/simulation_access.py,sha256=QHVEN-sEZbCCvblhBHEShGX0-NEXCD1
39
39
  bluecellulab/circuit/synapse_properties.py,sha256=6PpMWeothomR2c-mx63yVIISJc4eSL9xMnaIM2nryNM,5494
40
40
  bluecellulab/circuit/validate.py,sha256=7EUN15u0JFFlLf389jUBqLwDOHyZdfKtoidI-xLUVYA,3593
41
41
  bluecellulab/circuit/circuit_access/__init__.py,sha256=sgp6m5kP-pq60V1IFGUiSUR1OW01zdxXNNUJmPA8anI,201
42
- bluecellulab/circuit/circuit_access/bluepy_circuit_access.py,sha256=msAbAKH7XEPn77lTPA7-ntRiY-fCIxvLuA250gjo__Q,14681
42
+ bluecellulab/circuit/circuit_access/bluepy_circuit_access.py,sha256=HxQaRTz1HaeOVV87fiptJBXRNWCitT-5YHn71WtSsLg,14687
43
43
  bluecellulab/circuit/circuit_access/definition.py,sha256=SnKBFEgdXFG-QexYRrGSzVAd7bSj7NwN0IuTsjDOrDY,4435
44
- bluecellulab/circuit/circuit_access/sonata_circuit_access.py,sha256=P1ElK_VA10_JyyKbAnqzuAlduEYE2c_NSec2TZuix1U,10345
44
+ bluecellulab/circuit/circuit_access/sonata_circuit_access.py,sha256=c0MMJuoT6_dRW8O5HSRS5hHv1zDKdW0sBR-DaP0F1bk,10351
45
45
  bluecellulab/circuit/config/__init__.py,sha256=aaoJXRKBJzpxxREo9NxKc-_CCPmVeuR1mcViRXcLrC4,215
46
46
  bluecellulab/circuit/config/bluepy_simulation_config.py,sha256=tUyHvzlxFWRxh8rBNvU0FdUqGqJR2G8OXifATQ9W7yw,6974
47
47
  bluecellulab/circuit/config/definition.py,sha256=o0751Dd83f8TWGw95EAQ8coJrYGasdshrIrXViF5lzg,2774
@@ -53,17 +53,18 @@ bluecellulab/hoc/TDistFunc.hoc,sha256=WKX-anvL83xGuGPH9g1oIORB17UM4Pi3-iIXzKO-pU
53
53
  bluecellulab/hoc/TStim.hoc,sha256=noBJbM_ZqF6T6MEgBeowNzz21I9QeYZ5brGgUvCSm4k,8473
54
54
  bluecellulab/hoc/fileUtils.hoc,sha256=LSM7BgyjYVqo2DGSOKvg4W8IIusbsL45JVYK0vgwitU,2539
55
55
  bluecellulab/simulation/__init__.py,sha256=P2ebt0SFw-08J3ihN-LeRn95HeF79tzA-Q0ReLm32dM,214
56
- bluecellulab/simulation/neuron_globals.py,sha256=uxgceZ7zzbVEtITrQv8oOK900zhh7w29cScFwjLWo4I,4134
56
+ bluecellulab/simulation/neuron_globals.py,sha256=_8xmJPQMfCyhVn6KppK7i3jaUZaALMLgyxyHMKi02yo,4508
57
+ bluecellulab/simulation/parallel.py,sha256=xmlIelxYNct-vGhPip7_vF9gwyehdpomYB8kf9xV-S8,1314
57
58
  bluecellulab/simulation/simulation.py,sha256=I__cZwV_A8I7XSefn6aJDBA_jXCI3E35-pCNCLUsnvo,6206
58
59
  bluecellulab/stimulus/__init__.py,sha256=DgIgVaSyR-URf3JZzvO6j-tjCerzvktuK-ep8pjMRPQ,37
59
60
  bluecellulab/stimulus/circuit_stimulus_definitions.py,sha256=uij_s44uNdmMwMLGmTHSRgmp9K9B_vvHHshX6YPJNJU,15686
60
- bluecellulab/stimulus/factory.py,sha256=AOby3Sp2g8BJsRccz3afazfCyysyWIgLtcliWlyeiu0,8097
61
+ bluecellulab/stimulus/factory.py,sha256=cjnMqFx-Y31kV1XHvkSbGI2f1OpEawU3Wg_cLqcIyRc,11883
61
62
  bluecellulab/synapse/__init__.py,sha256=RW8XoAMXOvK7OG1nHl_q8jSEKLj9ZN4oWf2nY9HAwuk,192
62
63
  bluecellulab/synapse/synapse_factory.py,sha256=YkvxbdGF-u-vxYdbRNTlX-9AtSC_3t_FQRFhybwzgrk,6805
63
64
  bluecellulab/synapse/synapse_types.py,sha256=4gne-hve2vq1Lau-LAVPsfLjffVYqAYBW3kCfC7_600,16871
64
- bluecellulab-2.5.10.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
65
- bluecellulab-2.5.10.dist-info/LICENSE,sha256=xOouu1gC1GGklDxkITlaVl60I9Ab860O-nZsFbWydvU,11749
66
- bluecellulab-2.5.10.dist-info/METADATA,sha256=MEgGgaV3rXDUcTU5EntzGyw3GinZSWicJnC0cQuPrXo,7026
67
- bluecellulab-2.5.10.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
68
- bluecellulab-2.5.10.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
69
- bluecellulab-2.5.10.dist-info/RECORD,,
65
+ bluecellulab-2.6.0.dist-info/AUTHORS.txt,sha256=EDs3H-2HXBojbma10psixk3C2rFiOCTIREi2ZAbXYNQ,179
66
+ bluecellulab-2.6.0.dist-info/LICENSE,sha256=xOouu1gC1GGklDxkITlaVl60I9Ab860O-nZsFbWydvU,11749
67
+ bluecellulab-2.6.0.dist-info/METADATA,sha256=X-XmGZmXo-FZIe6H5r0qIs-VBJnTN0zNVOXNVuiLW0M,7025
68
+ bluecellulab-2.6.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
69
+ bluecellulab-2.6.0.dist-info/top_level.txt,sha256=VSyEP8w9l3pXdRkyP_goeMwiNA8KWwitfAqUkveJkdQ,13
70
+ bluecellulab-2.6.0.dist-info/RECORD,,