Skip to content

Commit

Permalink
fix #960: ruff linting in all notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
janfb committed Mar 6, 2024
1 parent 1f1f057 commit 9b07b1f
Show file tree
Hide file tree
Showing 16 changed files with 26,836 additions and 16,943 deletions.
181 changes: 81 additions & 100 deletions examples/00_HH_simulator.ipynb

Large diffs are not rendered by default.

177 changes: 101 additions & 76 deletions examples/01_decision_making_model.ipynb

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions examples/HH_helper_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ def syn_current(duration=120, dt=0.01, t_on=10, curr_level=5e-4, seed=None):

# external current
A_soma = np.pi * ((70.0 * 1e-4) ** 2) # cm2
I = np.zeros_like(t)
I[int(np.round(t_on / dt)) : int(np.round(t_off / dt))] = (
I_inj = np.zeros_like(t)
I_inj[int(np.round(t_on / dt)) : int(np.round(t_off / dt))] = (
curr_level / A_soma
) # muA/cm2

return I, t_on, t_off, dt, t, A_soma
return I_inj, t_on, t_off, dt, t, A_soma


def HHsimulator(V0, params, dt, t, I, seed=None):
def HHsimulator(V0, params, dt, t, I_inj, seed=None):
"""Simulates the Hodgkin-Huxley model for a specified time duration and current
Parameters
Expand Down Expand Up @@ -144,7 +144,7 @@ def tau_p(x):
+ (n[i - 1] ** 4) * gbar_K * E_K
+ g_leak * E_leak
+ gbar_M * p[i - 1] * E_K
+ I[i - 1]
+ I_inj[i - 1]
+ nois_fact * rng.randn() / (tstep**0.5)
) / (tau_V_inv * C)
V[i] = V_inf + (V[i - 1] - V_inf) * np.exp(-tstep * tau_V_inv)
Expand All @@ -167,7 +167,7 @@ def calculate_summary_statistics(x):
-------
np.array, summary statistics
"""
I, t_on, t_off, dt, t, A_soma = syn_current()
I_inj, t_on, t_off, dt, t, A_soma = syn_current()

n_mom = 4
n_summary = 7
Expand Down
150 changes: 100 additions & 50 deletions tutorials/03_multiround_inference.ipynb

Large diffs are not rendered by default.

21 changes: 17 additions & 4 deletions tutorials/04_density_estimators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,23 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import torch\n",
"\n",
"from sbi.inference import SNPE, SNRE\n",
"from sbi.utils import BoxUniform"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"prior = BoxUniform(torch.zeros(2), torch.ones(2))\n",
"inference = SNPE(prior=prior, density_estimator=\"maf\")"
]
},
Expand All @@ -46,7 +59,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -71,7 +84,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -124,7 +137,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.5"
"version": "3.8.18"
}
},
"nbformat": 4,
Expand Down
113 changes: 55 additions & 58 deletions tutorials/05_embedding_net.ipynb

Large diffs are not rendered by default.

41,915 changes: 25,818 additions & 16,097 deletions tutorials/07_conditional_distributions.ipynb

Large diffs are not rendered by default.

96 changes: 48 additions & 48 deletions tutorials/08_restriction_estimator.ipynb

Large diffs are not rendered by default.

90 changes: 43 additions & 47 deletions tutorials/09_sensitivity_analysis.ipynb

Large diffs are not rendered by default.

181 changes: 81 additions & 100 deletions tutorials/10_crafting_summary_statistics.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 9b07b1f

Please sign in to comment.