Skip to content

Commit

Permalink
Fixed Link error
Browse files Browse the repository at this point in the history
  • Loading branch information
samadpls committed Jul 5, 2024
1 parent 7ba6e2a commit efa5de5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 29 deletions.
8 changes: 0 additions & 8 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,6 @@ Parallel backends (:py:mod:`hnn_core.parallel_backends`):
MPIBackend
JoblibBackend

Batch Simulation (:py:mod:`hnn_core.batch_simulate`):
---------------------------------------------------------
.. currentmodule:: hnn_core.batch_simulate

.. autosummary::
:toctree: generated/

BatchSimulate

Input and Output:
-----------------
Expand Down
16 changes: 10 additions & 6 deletions examples/howto/plot_batch_simulate.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
====================
06. Batch Simulation
07. Batch Simulation
====================
This example shows how to do batch simulations in HNN-core, allowing users to
Expand All @@ -13,17 +13,17 @@
# Ryan Thorpe <[email protected]>
# Mainak Jas <[email protected]>

#############################################################################
# Let us import hnn_core.
###############################################################################
# Let us import ``hnn_core``.

import hnn_core
import numpy as np
from hnn_core import BatchSimulate
from hnn_core.batch_simulate import BatchSimulate
from hnn_core import jones_2009_model

# The number of cores may need modifying depending on your current machine.
n_jobs = 10
###########################################################################
###############################################################################


def set_params(param_values, net=None):
Expand Down Expand Up @@ -57,7 +57,8 @@ def set_params(param_values, net=None):
weights_ampa=weights_ampa,
synaptic_delays=synaptic_delays)

###########################################################################
###############################################################################
# Define a parameter grid for the batch simulation.


param_grid = {
Expand All @@ -67,6 +68,9 @@ def set_params(param_values, net=None):
'sigma': np.linspace(1, 20, 5)
}

###############################################################################
# Run the batch simulation and collect the results.

batch_simulation = BatchSimulate(set_params=set_params)
simulation_results = batch_simulation.run(param_grid,
n_jobs=n_jobs,
Expand Down
1 change: 0 additions & 1 deletion hnn_core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@
from .cell_response import CellResponse, read_spikes
from .cells_default import pyramidal, basket
from .parallel_backends import MPIBackend, JoblibBackend
from .batch_simulate import BatchSimulate

__version__ = '0.4.dev0'
25 changes: 12 additions & 13 deletions hnn_core/batch_simulate.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Batch simulation."""
"""Batch Simulation."""

# Authors: Abdul Samad Siddiqui <[email protected]>
# Nick Tolley <[email protected]>
Expand All @@ -8,21 +8,24 @@
from joblib import Parallel, delayed
from .dipole import simulate_dipole
from .network_models import (jones_2009_model,
calcium_model, law_2021_model)
calcium_model, law_2021_model)


class BatchSimulate:
def __init__(self, set_params, net_name='jones', tstop=170,
dt=0.025, n_trials=1, record_vsec=False,
record_isec=False, postproc=False):
"""
Initialize the BatchSimulate class.
"""Initialize the BatchSimulate class.
Parameters
----------
set_params : func
User-defined function that sets parameters in network drives.
`set_params(net, params) -> None`
``set_params(net, params) -> None``
where ``net`` is a Network object and ``params`` is a dictionary
of the parameters that will be set inside the function.
net_name : str
The name of the network model to use. Default is `jones`.
tstop : float, optional
Expand Down Expand Up @@ -59,8 +62,7 @@ def __init__(self, set_params, net_name='jones', tstop=170,
self.postproc = postproc

def run(self, param_grid, return_output=True, combinations=True, n_jobs=1):
"""
Run batch simulations.
"""Run batch simulations.
Parameters
----------
Expand Down Expand Up @@ -88,8 +90,7 @@ def run(self, param_grid, return_output=True, combinations=True, n_jobs=1):
return results

def simulate_batch(self, param_combinations, n_jobs=1):
"""
Simulate a batch of parameter sets in parallel.
"""Simulate a batch of parameter sets in parallel.
Parameters
----------
Expand All @@ -113,8 +114,7 @@ def simulate_batch(self, param_combinations, n_jobs=1):
return res

def _run_single_sim(self, param_values):
"""
Run a single simulation.
"""Run a single simulation.
Parameters
----------
Expand Down Expand Up @@ -154,8 +154,7 @@ def _run_single_sim(self, param_values):
return {'net': net, 'dpl': dpl, 'param_values': param_values}

def _generate_param_combinations(self, param_grid, combinations=True):
"""
Generate combinations of parameters from the grid.
"""Generate combinations of parameters from the grid.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion hnn_core/tests/test_batch_simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
import numpy as np

from hnn_core import BatchSimulate
from hnn_core.batch_simulate import BatchSimulate


@pytest.fixture
Expand Down

0 comments on commit efa5de5

Please sign in to comment.