def test_get_filepath_point(): with copy_config() as config_copy_path: with edit_config(config_copy_path) as config: config["components"][ "point_neuron_models_dir"] = "$COMPONENT_DIR/point_neuron_models" circuit = Circuit(config_copy_path) nodes = create_node_population(str(TEST_DATA_DIR / "nodes_points.h5"), "default", circuit) test_obj = test_module.NeuronModelsHelper(circuit.config["components"], nodes) node_id = 0 assert nodes.get(node_id, properties=Node.MODEL_TEMPLATE) == "nml:empty_bio" actual = test_obj.get_filepath(node_id) expected = Path( circuit.config["components"]["point_neuron_models_dir"], "empty_bio.nml") assert actual == expected node_id = 1 assert nodes.get( node_id, properties=Node.MODEL_TEMPLATE) == "nml:/abs/path/empty_bio" actual = test_obj.get_filepath(node_id) expected = Path("/abs/path/empty_bio.nml") assert actual == expected
def circuit(self): """Access to the circuit used for the simulation.""" from bluepysnap.circuit import Circuit if "network" not in self._config: raise BluepySnapError( "No 'network' set in the simulation/global config file.") return Circuit(self._config["network"])
def test_as_edge_source_target(self): circuit = Circuit(str(TEST_DATA_DIR / 'circuit_config.json')) assert circuit.nodes['default'].source_in_edges() == { "default", 'default2' } assert circuit.nodes['default'].target_in_edges() == { "default", 'default2' }
def test_as_edge_source_target(self): circuit = Circuit(str(TEST_DATA_DIR / "circuit_config.json")) assert circuit.nodes["default"].source_in_edges() == { "default", "default2" } assert circuit.nodes["default"].target_in_edges() == { "default", "default2" }
def test_property_dtypes_fail(self): a = pd.Series(data=[dtype('int64'), dtype('float64')], index=['syn_weight', 'efferent_surface_z']).sort_index() b = pd.Series(data=[dtype('int32'), dtype('float64')], index=['syn_weight', 'efferent_surface_z']).sort_index() with patch("bluepysnap.edges.EdgePopulation.property_dtypes", new_callable=PropertyMock) as mock: mock.side_effect = [a, b] circuit = Circuit(str(TEST_DATA_DIR / 'circuit_config.json')) test_obj = test_module.Edges(circuit) with pytest.raises(BluepySnapError): test_obj.property_dtypes.sort_index()
def test_property_dtypes_fail(self): a = pd.Series(data=[dtype('int64'), dtype('O')], index=['layer', 'model_template']).sort_index() b = pd.Series(data=[dtype('int32'), dtype('O')], index=['layer', 'model_template']).sort_index() with patch("bluepysnap.nodes.NodePopulation.property_dtypes", new_callable=PropertyMock) as mock: mock.side_effect = [a, b] circuit = Circuit(str(TEST_DATA_DIR / 'circuit_config.json')) test_obj = test_module.Nodes(circuit) with pytest.raises(BluepySnapError): test_obj.property_dtypes.sort_index()
def test_biophysical_in_library(self): with copy_circuit() as (circuit_copy_path, config_copy_path): with edit_config(config_copy_path) as config: config["networks"]["nodes"][0]["nodes_file"] = "$NETWORK_DIR/nodes_quaternions.h5" nodes_file = circuit_copy_path / 'nodes_quaternions.h5' with h5py.File(nodes_file, 'r+') as h5f: data = h5f['nodes/default/0/model_type'][:] del h5f['nodes/default/0/model_type'] h5f.create_dataset('nodes/default/0/model_type', data=np.zeros_like(data, dtype=int)) h5f.create_dataset('nodes/default/0/@library/model_type', data=np.array(["biophysical", ], dtype=h5py.string_dtype())) circuit = Circuit(str(config_copy_path)) assert isinstance(circuit.nodes['default'].morph, test_module.MorphHelper)
def test_not_biophysical_population(self): with copy_circuit() as (circuit_copy_path, config_copy_path): with edit_config(config_copy_path) as config: config["networks"]["nodes"][0]["nodes_file"] = "$NETWORK_DIR/nodes_quaternions.h5" nodes_file = circuit_copy_path / 'nodes_quaternions.h5' with h5py.File(nodes_file, 'r+') as h5f: data = h5f['nodes/default/0/model_type'][:] del h5f['nodes/default/0/model_type'] h5f.create_dataset('nodes/default/0/model_type', data=np.zeros_like(data, dtype=int)) h5f.create_dataset('nodes/default/0/@library/model_type', data=np.array(["virtual", ], dtype=h5py.string_dtype())) with pytest.raises(BluepySnapError): circuit = Circuit(str(config_copy_path)) circuit.nodes['default'].morph
def setup(self): circuit = Circuit(str(TEST_DATA_DIR / 'circuit_config.json')) self.test_obj = test_module.Edges(circuit)
def setup(self): circuit = Circuit(str(TEST_DATA_DIR / "circuit_config.json")) self.test_obj = test_module.Nodes(circuit)