Internals¶
Progress bars¶
- class pigreads.progress.BaseProgressIterator(iterable)¶
-
Base class for progress iterators.
- class pigreads.progress.JSONProgressIterator(iterable, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)¶
Bases:
BaseProgressIterator[T]JSON progress iterator.
This progress indicator prints the current index, total number of items, time elapsed, time remaining, and time per iteration in JSON format.
- Parameters:
- Variables:
total – Total number of items.
file – File object to write progress to.
index – The current index.
start – Start time.
- pigreads.progress.PROGRESS_ITERS: dict[str, Callable[[Any], Any]]¶
Mapping of progress bar types to progress indicators.
Options:
“bar”: a bar with detailed progress information
“json”: JSON progress information
“plain”: plain text progress information
“none”: no progress information
- class pigreads.progress.PlainProgressIterator(iterable, file=<_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>)¶
Bases:
BaseProgressIterator[T]Plain progress iterator.
This progress indicator simply prints the current index and total number of items.
- Parameters:
- Variables:
total – Total number of items.
file – File object to write progress to.
index – The current index.
- class pigreads.progress.T¶
abstract type variable for generic types
alias of TypeVar(‘T’)
Low-level implementation¶
- class pigreads.core.Models(double_precision=False, context=None)¶
Bases:
objectCore implementation of the
Modelsclass.- See:
pigreads.models.Modelsfor the main interface to the models.- Parameters:
- add(key, code, Nv, params)¶
Select and enable a model with given parameters.
- adjust_work_size(Nz, Ny, Nx)¶
Slightly increase the global work size to be a multiple of the local work size.
- compile(code)¶
Compile the given OpenCL code.
- get_block_size()¶
Get the local work size for running OpenCL kernels.
- get_key(imodel)¶
Get the key of the model with the given index.
- get_number_definitions()¶
Get the number of model definitions.
- Return type:
- Returns:
Number of model definitions
- get_parameter(imodel, iparam)¶
Get the parameter with the given indices.
- property queue: CommandQueue¶
The OpenCL command queue used for computations.
- run(inhom, weights, states, stim_signal, stim_shape, Nt, dt)¶
Run a Pigreads simulation.
- Parameters:
inhom (
ndarray[Any,Any]) – A 3D array with integer values, encoding which model to use at each point. Its value is zero for points outside the medium and one or more for points inside. Values larger than zero are used to select one of multiple models: 1 formodels[0], 2 formodels[1], etc.weights (
ndarray[Any,Any]) – The weights for the diffusion term, seeweights().states (
ndarray[Any,Any]) – The initial states of the simulation, a 4D array of shape (Nz, Ny, Nx, Nv).stim_signal (
ndarray[Any,Any]) – A 3D array with the stimulus signal at each time point for all variables, with shape (Nt, Ns, Nv).stim_shape (
ndarray[Any,Any]) – A 4D array specifying the shape of the stimulus, with shape (Ns, Nz, Ny, Nx).Nt (
Any) – The number of time steps to run the simulation for.dt (
Any) – The time step size.
- Return type:
- set_block_size(block_size)¶
Set the local work size for running OpenCL kernels.
- set_parameter(imodel, iparam, value)¶
Set the parameter with the given indices.
- weights(dz, dy, dx, mask, diffusivity)¶
Calculate the weights for the diffusion term in the reaction-diffusion equation.
- Parameters:
- Return type:
- Returns:
Weight matrix for the diffusion term, A 5D array of shape (1, Nz, Ny, Nx, 19).