Skip to content

Commit

Permalink
fixed bug in conn, updated test/examples/* to use dynamic pathing (#817)
Browse files Browse the repository at this point in the history
* fixed bug in conn, updated test/examples/* to use dynamic pathing

* update CHANGES.md
  • Loading branch information
jchen6727 committed May 11, 2024
1 parent 703435c commit 6f16803
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 32 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

- cfg.connRandomSecFromList and cfg.distributeSynsUniformly can now be overriden in individual conn rule

- Updated tests.examples.utils to allow for dynamic pathing

**Bug fixes**

- Better handling of exceptions in `importCellParams()` (incl. issue 782)
Expand Down
2 changes: 1 addition & 1 deletion netpyne/network/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def probConn(self, preCellsTags, postCellsTags, connParam):
if sim.cfg.verbose:
print('Generating set of probabilistic connections (rule: %s) ...' % (connParam['label']))
if sim.rank == 0 and not sim.cfg.verbose: pbar = tqdm(total=len(postCellsTags.items()), ascii=True,
desc=' ' + connParam['label'], position=0, leave=True,
desc=' ' + str(connParam['label']), position=0, leave=True,
bar_format= '{l_bar}{bar}| Creating synaptic connections for {n_fmt}/{total_fmt} postsynaptic cells on node %i (probabilistic connectivity)' % sim.rank)

allRands = self.generateRandsPrePost(preCellsTags, postCellsTags)
Expand Down
5 changes: 3 additions & 2 deletions tests/examples/test_HHTut.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR

@pytest.mark.package_data(['examples/HHTut/', None])
package_dir = NETPYNE_DIR + '/examples/HHTut/'
@pytest.mark.package_data([package_dir, None])
class TestHHTut():
def test_run(self, pkg_setup):
import src.init
Expand Down
6 changes: 4 additions & 2 deletions tests/examples/test_HybridTut.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR

@pytest.mark.package_data(['examples/HybridTut/', 'mod'])
package_dir = NETPYNE_DIR + '/examples/HybridTut/'

@pytest.mark.package_data([package_dir, 'mod'])
class TestHybridTut:
def test_run(self, pkg_setup):
import src.init
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/test_LFPrecording.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(['examples/LFPrecording/', 'mod'])
package_dir = NETPYNE_DIR + '/examples/LFPrecording/'
@pytest.mark.package_data([package_dir, 'mod'])
class TestLFPrecording:
def test_cell_lfp(self, pkg_setup):
import src.cell.init
6 changes: 3 additions & 3 deletions tests/examples/test_M1.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(['examples/M1/', 'mod'])
package_dir = NETPYNE_DIR + '/examples/M1/'
@pytest.mark.package_data([package_dir, 'mod'])
class TestM1:
def test_run(self, pkg_setup):
import src.init
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/test_NeuroMLImport.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(['examples/NeuroMLImport/', '.'])
package_dir = NETPYNE_DIR + '/examples/NeuroMLImport/'
@pytest.mark.package_data([package_dir, '.'])
class TestPTcell:
def test_init(self, pkg_setup):
import SimpleNet_import
6 changes: 3 additions & 3 deletions tests/examples/test_PTcell.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(['examples/PTcell/', 'mod'])
package_dir = NETPYNE_DIR + '/examples/PTcell/'
@pytest.mark.package_data([package_dir, 'mod'])
class TestPTcell:
def test_init(self, pkg_setup):
import src.init
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/test_batchCell.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
if "-nogui" not in sys.argv:
sys.argv.append("-nogui")

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(["examples/batchCell/", "mod"])
package_dir = NETPYNE_DIR + "/examples/batchCell/"
@pytest.mark.package_data([package_dir, "mod"])
class TestBatchCell:
def batch_run(self, pkg_setup):
"""run a reduced version of the batchCell example"""
Expand Down
6 changes: 3 additions & 3 deletions tests/examples/test_evolCell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
if "-nogui" not in sys.argv:
sys.argv.append("-nogui")

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(["examples/evolCell/", "mod"])
package_dir = NETPYNE_DIR + "/examples/evolCell/"
@pytest.mark.package_data([package_dir, "mod"])
class TestEvolCell:
def evol_run(self, pkg_setup):
"""run a reduced version of the evolCell example"""
Expand Down
5 changes: 3 additions & 2 deletions tests/examples/test_rxd_buffering.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR

@pytest.mark.package_data(['examples/rxd_buffering/', None])
package_dir = NETPYNE_DIR + '/examples/rxd_buffering/'
@pytest.mark.package_data([package_dir, None])
class Test_rxd_buffering():
def test_buffering(self, pkg_setup):
import src.init
6 changes: 3 additions & 3 deletions tests/examples/test_rxd_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
if '-nogui' not in sys.argv:
sys.argv.append('-nogui')

from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(['examples/rxd_net/', 'mod'])
package_dir = NETPYNE_DIR + '/examples/rxd_net/'
@pytest.mark.package_data([package_dir, 'mod'])
class TestRxdNet:
def test_init(self, pkg_setup):
import src.init
6 changes: 3 additions & 3 deletions tests/examples/test_saving.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
sys.argv.append('-nogui')


from .utils import pkg_setup
from .utils import pkg_setup, NETPYNE_DIR


@pytest.mark.package_data(['examples/saving', None])
package_dir = NETPYNE_DIR + '/examples/saving/'
@pytest.mark.package_data([package_dir, None])
class Test_saving():
def test_init(self, pkg_setup):
import src.init
Expand Down
4 changes: 3 additions & 1 deletion tests/examples/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import os
import pytest
import sys
import inspect
import netpyne

NETPYNE_DIR = '/' + os.path.join(*inspect.getfile(netpyne).split('/')[:-2])
def compile_neuron_mod_dir(pkg_dir):
try:
print('Compiling {}'.format(pkg_dir))
Expand All @@ -14,7 +17,6 @@ def compile_neuron_mod_dir(pkg_dir):
print(err)
return


@pytest.fixture
def pkg_setup(request):
mark = request.node.get_closest_marker("package_data")
Expand Down

0 comments on commit 6f16803

Please sign in to comment.