本文整理汇总了Python中tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory.create_connectivity方法的典型用法代码示例。如果您正苦于以下问题:Python DatatypesFactory.create_connectivity方法的具体用法?Python DatatypesFactory.create_connectivity怎么用?Python DatatypesFactory.create_connectivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory
的用法示例。
在下文中一共展示了DatatypesFactory.create_connectivity方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_launchable_algorithms
# 需要导入模块: from tvb.tests.framework.datatypes.datatypes_factory import DatatypesFactory [as 别名]
# 或者: from tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory import create_connectivity [as 别名]
def test_get_launchable_algorithms(self):
factory = DatatypesFactory()
conn = factory.create_connectivity(4)[1]
ts = factory.create_timeseries(conn)
result = self.flow_service.get_launchable_algorithms(ts.gid)
self.assertTrue('Analyze' in result)
self.assertTrue('View' in result)
示例2: transactional_setup_method
# 需要导入模块: from tvb.tests.framework.datatypes.datatypes_factory import DatatypesFactory [as 别名]
# 或者: from tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory import create_connectivity [as 别名]
def transactional_setup_method(self):
self.init()
self.surface_m_p_c = SurfaceModelParametersController()
BurstController().index()
stored_burst = cherrypy.session[common.KEY_BURST_CONFIG]
datatypes_factory = DatatypesFactory()
_, self.connectivity = datatypes_factory.create_connectivity()
_, self.surface = datatypes_factory.create_surface()
new_params = {}
for key, val in SIMULATOR_PARAMETERS.iteritems():
new_params[key] = {'value': val}
new_params['connectivity'] = {'value': self.connectivity.gid}
new_params['surface'] = {'value': self.surface.gid}
stored_burst.simulator_configuration = new_params
示例3: NIFTIImporterTest
# 需要导入模块: from tvb.tests.framework.datatypes.datatypes_factory import DatatypesFactory [as 别名]
# 或者: from tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory import create_connectivity [as 别名]
#.........这里部分代码省略.........
'apply_corrections': True, 'connectivity': connectivity}
### Launch import Operation
FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args)
dts, count = dao.get_values_of_datatype(self.test_project.id, expected_result_class, None)
self.assertEqual(1, count, "Project should contain only one data type.")
result = ABCAdapter.load_entity_by_gid(dts[0][2])
self.assertTrue(result is not None, "Result should not be none")
return result
def test_import_demo_ts(self):
"""
This method tests import of a NIFTI file.
"""
time_series = self._import(self.TIMESERIES_NII_FILE, TimeSeriesVolume)
# Since self.assertAlmostEquals is not available on all machine
# We compare floats as following
self.assertTrue(abs(1.0 - time_series.sample_period) <= 0.001)
self.assertEqual("sec", str(time_series.sample_period_unit))
self.assertEqual(0.0, time_series.start_time)
self.assertTrue(time_series.title.startswith("NIFTI"))
data_shape = time_series.read_data_shape()
self.assertEquals(4, len(data_shape))
# We have 5 time points
self.assertEqual(5, data_shape[0])
dimension_labels = time_series.labels_ordering
self.assertTrue(dimension_labels is not None)
self.assertEquals(4, len(dimension_labels))
volume = time_series.volume
self.assertTrue(volume is not None)
self.assertTrue(numpy.equal(self.DEFAULT_ORIGIN, volume.origin).all())
self.assertEquals("mm", volume.voxel_unit)
def test_import_nii_without_time_dimension(self):
"""
This method tests import of a NIFTI file.
"""
structure = self._import(self.NII_FILE)
self.assertEqual("T1", structure.weighting)
data_shape = structure.array_data.shape
self.assertEquals(3, len(data_shape))
self.assertEqual(64, data_shape[0])
self.assertEqual(64, data_shape[1])
self.assertEqual(10, data_shape[2])
volume = structure.volume
self.assertTrue(volume is not None)
self.assertTrue(numpy.equal(self.DEFAULT_ORIGIN, volume.origin).all())
self.assertTrue(numpy.equal([3.0, 3.0, 3.0], volume.voxel_size).all())
self.assertEquals(self.UNKNOWN_STR, volume.voxel_unit)
def test_import_nifti_compressed(self):
"""
This method tests import of a NIFTI file compressed in GZ format.
"""
structure = self._import(self.GZ_NII_FILE)
self.assertEqual("T1", structure.weighting)
def test_import_region_mapping(self):
"""
This method tests import of a NIFTI file compressed in GZ format.
"""
to_link_conn = self.datatypeFactory.create_connectivity()[1]
mapping = self._import(self.GZ_NII_FILE, RegionVolumeMapping, to_link_conn.gid)
self.assertTrue(-1 <= mapping.array_data.min())
self.assertTrue(mapping.array_data.max() < to_link_conn.number_of_regions)
conn = mapping.connectivity
self.assertTrue(conn is not None)
self.assertEquals(to_link_conn.number_of_regions, conn.number_of_regions)
volume = mapping.volume
self.assertTrue(volume is not None)
self.assertTrue(numpy.equal(self.DEFAULT_ORIGIN, volume.origin).all())
self.assertTrue(numpy.equal([3.0, 3.0, 3.0], volume.voxel_size).all())
self.assertEquals(self.UNKNOWN_STR, volume.voxel_unit)
def test_import_wrong_nii_file(self):
"""
This method tests import of a file in a wrong format
"""
try:
self._import(self.WRONG_NII_FILE)
self.fail("Import should fail in case of a wrong NIFTI format.")
except OperationException:
# Expected exception
pass
示例4: SimulatorAdapterTest
# 需要导入模块: from tvb.tests.framework.datatypes.datatypes_factory import DatatypesFactory [as 别名]
# 或者: from tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory import create_connectivity [as 别名]
class SimulatorAdapterTest(TransactionalTestCase):
"""
Basic testing that Simulator is still working from UI.
"""
CONNECTIVITY_NODES = 74
def setUp(self):
"""
Reset the database before each test.
"""
initialize_storage()
self.datatypes_factory = DatatypesFactory()
self.test_user = self.datatypes_factory.get_user()
self.test_project = self.datatypes_factory.get_project()
self.connectivity = self.datatypes_factory.create_connectivity(self.CONNECTIVITY_NODES)[1]
algorithm = dao.get_algorithm_by_module(SIMULATOR_MODULE, SIMULATOR_CLASS)
self.simulator_adapter = ABCAdapter.build_adapter(algorithm)
self.operation = TestFactory.create_operation(algorithm, self.test_user, self.test_project,
model.STATUS_STARTED, json.dumps(SIMULATOR_PARAMETERS))
SIMULATOR_PARAMETERS['connectivity'] = self.connectivity.gid
def test_happy_flow_launch(self):
"""
Test that launching a simulation from UI works.
"""
OperationService().initiate_prelaunch(self.operation, self.simulator_adapter, {}, **SIMULATOR_PARAMETERS)
sim_result = dao.get_generic_entity(TimeSeriesRegion, 'TimeSeriesRegion', 'type')[0]
self.assertEquals(sim_result.read_data_shape(), (32, 1, self.CONNECTIVITY_NODES, 1))
def _estimate_hdd(self, new_parameters_dict):
""" Private method, to return HDD estimation for a given set of input parameters"""
filtered_params = self.simulator_adapter.prepare_ui_inputs(new_parameters_dict)
self.simulator_adapter.configure(**filtered_params)
return self.simulator_adapter.get_required_disk_size(**filtered_params)
def test_estimate_hdd(self):
"""
Test that occupied HDD estimation for simulation results considers simulation length.
"""
factor = 5
simulation_parameters = copy(SIMULATOR_PARAMETERS)
## Estimate HDD with default simulation parameters
estimate1 = self._estimate_hdd(simulation_parameters)
self.assertTrue(estimate1 > 1)
## Change simulation length and monitor period, we expect a direct proportial increase in estimated HDD
simulation_parameters['simulation_length'] = float(simulation_parameters['simulation_length']) * factor
period = float(simulation_parameters['monitors_parameters_option_TemporalAverage_period'])
simulation_parameters['monitors_parameters_option_TemporalAverage_period'] = period / factor
estimate2 = self._estimate_hdd(simulation_parameters)
self.assertEqual(estimate1, estimate2 / factor / factor)
## Change number of nodes in connectivity. Expect HDD estimation increase.
large_conn_gid = self.datatypes_factory.create_connectivity(self.CONNECTIVITY_NODES * factor)[1].gid
simulation_parameters['connectivity'] = large_conn_gid
estimate3 = self._estimate_hdd(simulation_parameters)
self.assertEqual(estimate2, estimate3 / factor)
def test_estimate_execution_time(self):
"""
Test that get_execution_time_approximation considers the correct params
"""
## Compute reference estimation
params = self.simulator_adapter.prepare_ui_inputs(SIMULATOR_PARAMETERS)
estimation1 = self.simulator_adapter.get_execution_time_approximation(**params)
## Estimation when the surface input parameter is set
params['surface'] = "GID_surface"
estimation2 = self.simulator_adapter.get_execution_time_approximation(**params)
self.assertEqual(estimation1, estimation2 / 500)
params['surface'] = ""
## Modify integration step and simulation length:
initial_simulation_length = float(params['simulation_length'])
initial_integration_step = float(params['integrator_parameters']['dt'])
for factor in (2, 4, 10):
params['simulation_length'] = initial_simulation_length * factor
params['integrator_parameters']['dt'] = initial_integration_step / factor
estimation3 = self.simulator_adapter.get_execution_time_approximation(**params)
self.assertEqual(estimation1, estimation3 / factor / factor)
## Check that no division by zero happens
params['integrator_parameters']['dt'] = 0
estimation4 = self.simulator_adapter.get_execution_time_approximation(**params)
self.assertTrue(estimation4 > 0)
## even with length zero, still a positive estimation should be returned
params['simulation_length'] = 0
estimation5 = self.simulator_adapter.get_execution_time_approximation(**params)
self.assertTrue(estimation5 > 0)
#.........这里部分代码省略.........