import unittest import arbor as arb # to be able to run .py file from child directory import sys, os sys.path.insert( 0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))) try: import options except ModuleNotFoundError: from test import options # check Arbor's configuration of mpi config = arb.config() mpi_enabled = config["mpi"] """ all tests for distributed arb.context using arbor mpi wrappers """ @unittest.skipIf(mpi_enabled == False, "MPI not enabled") class Contexts_arbmpi(unittest.TestCase): # Initialize mpi only once in this class (when adding classes move initialization to setUpModule() @classmethod def setUpClass(self): self.local_mpi = False if not arb.mpi_is_initialized(): arb.mpi_init() self.local_mpi = True
import sys import arbor use_mpi = arbor.config()['mpi'] if use_mpi: import mpi4py.MPI as MPI class ring_recipe(arbor.recipe): def __init__(self, n=4): # The base C++ class constructor must be called first, to ensure that # all memory in the C++ class is initialized correctly. arbor.recipe.__init__(self) self.ncells = n self.params = arbor.cell_parameters() # The num_cells method that returns the total number of cells in the model # must be implemented. def num_cells(self): return self.ncells # The cell_description method returns a cell def cell_description(self, gid): return arbor.make_cable_cell(gid, self.params) def num_targets(self, gid): return 1 def num_sources(self, gid): return 1