From efa5de529db2040a82f3615ce94449cd91c269e0 Mon Sep 17 00:00:00 2001 From: Abdul Samad Siddiqui Date: Fri, 5 Jul 2024 20:38:01 +0500 Subject: [PATCH] Fixed Link error --- doc/api.rst | 8 -------- examples/howto/plot_batch_simulate.py | 16 ++++++++++------ hnn_core/__init__.py | 1 - hnn_core/batch_simulate.py | 25 ++++++++++++------------- hnn_core/tests/test_batch_simulate.py | 2 +- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/doc/api.rst b/doc/api.rst index ef75e4b1d0..2b550ad2a4 100644 --- a/doc/api.rst +++ b/doc/api.rst @@ -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: ----------------- diff --git a/examples/howto/plot_batch_simulate.py b/examples/howto/plot_batch_simulate.py index 1c4882e7cf..f9ecc150a7 100644 --- a/examples/howto/plot_batch_simulate.py +++ b/examples/howto/plot_batch_simulate.py @@ -1,6 +1,6 @@ """ ==================== -06. Batch Simulation +07. Batch Simulation ==================== This example shows how to do batch simulations in HNN-core, allowing users to @@ -13,17 +13,17 @@ # Ryan Thorpe # Mainak Jas -############################################################################# -# 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): @@ -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 = { @@ -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, diff --git a/hnn_core/__init__.py b/hnn_core/__init__.py index 238a9ed045..876d9d2df3 100644 --- a/hnn_core/__init__.py +++ b/hnn_core/__init__.py @@ -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' diff --git a/hnn_core/batch_simulate.py b/hnn_core/batch_simulate.py index b0a04d4ad5..1a91737cd4 100644 --- a/hnn_core/batch_simulate.py +++ b/hnn_core/batch_simulate.py @@ -1,4 +1,4 @@ -"""Batch simulation.""" +"""Batch Simulation.""" # Authors: Abdul Samad Siddiqui # Nick Tolley @@ -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 @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- diff --git a/hnn_core/tests/test_batch_simulate.py b/hnn_core/tests/test_batch_simulate.py index c120dbbda1..3a77e96b18 100644 --- a/hnn_core/tests/test_batch_simulate.py +++ b/hnn_core/tests/test_batch_simulate.py @@ -6,7 +6,7 @@ import pytest import numpy as np -from hnn_core import BatchSimulate +from hnn_core.batch_simulate import BatchSimulate @pytest.fixture