Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG] Fix legacy param reading for legacy_mode=False #614

Merged
merged 2 commits into from Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whats_new.rst
Expand Up @@ -75,6 +75,9 @@ Bug
- Fix bug where :func:`~hnn_core.network.add_evoked_drive` failed when adding
a drive with just NMDA weights, by `Nick Tolley`_ in :gh:`611`

- Fix bug where :func:`~hnn_core.params.read_params` failed to create a network when
legacy mode is False, by `Nick Tolley`_ in :gh:`614`

API
~~~
- Optimization of the evoked drives can be conducted on any :class:`~hnn_core.Network`
Expand Down
6 changes: 6 additions & 0 deletions hnn_core/drives.py
Expand Up @@ -145,6 +145,9 @@ def _add_drives_from_params(net):
synaptic_delays=specs['synaptic_delays'],
space_constant=specs['space_constant'])
elif specs['type'] == 'poisson':
if (not net._legacy_mode) and specs[
'dynamics']['tstop'] < specs['dynamics']['tstart']:
continue
net.add_poisson_drive(
drive_name, tstart=specs['dynamics']['tstart'],
tstop=specs['dynamics']['tstop'],
Expand All @@ -165,6 +168,9 @@ def _add_drives_from_params(net):
synaptic_delays=specs['synaptic_delays'],
space_constant=specs['space_constant'])
elif specs['type'] == 'bursty':
if (not net._legacy_mode) and specs[
'dynamics']['tstop'] < specs['dynamics']['tstart']:
continue
net.add_bursty_drive(
drive_name,
tstart=specs['dynamics']['tstart'],
Expand Down
7 changes: 6 additions & 1 deletion hnn_core/tests/test_params.py
Expand Up @@ -8,14 +8,19 @@
import pytest

import hnn_core
from hnn_core import read_params, Params
from hnn_core import read_params, Params, jones_2009_model
hnn_core_root = op.dirname(hnn_core.__file__)


def test_read_params():
"""Test reading of params object."""
params_fname = op.join(hnn_core_root, 'param', 'default.json')
params = read_params(params_fname)
# Smoke test that network loads params
_ = jones_2009_model(
params, add_drives_from_params=True, legacy_mode=False)
_ = jones_2009_model(
params, add_drives_from_params=True, legacy_mode=True)
print(params)
print(params['L2Pyr*'])

Expand Down