当前位置: 首页>>代码示例>>Python>>正文


Python datatypes_factory.DatatypesFactory类代码示例

本文整理汇总了Python中tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory的典型用法代码示例。如果您正苦于以下问题:Python DatatypesFactory类的具体用法?Python DatatypesFactory怎么用?Python DatatypesFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DatatypesFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

    def setUp(self):
        """
        Sets up the environment for running the tests;
        creates a test user, a test project, a datatype and a datatype_group;
        """
        export_manager = ExportManager()

        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()

        # Generate simple data type and export it to H5 file
        self.datatype = self.datatypeFactory.create_datatype_with_storage()
        _, exported_h5_file, _ = export_manager.export_data(self.datatype, self.TVB_EXPORTER, self.test_project)
        # Copy H5 file to another location since the original one / exported 
        # will be deleted with the project
        _, h5_file_name = os.path.split(exported_h5_file)
        shutil.copy(exported_h5_file, TvbProfile.current.TVB_TEMP_FOLDER)
        self.h5_file_path = os.path.join(TvbProfile.current.TVB_TEMP_FOLDER, h5_file_name)

        self.assertTrue(os.path.exists(self.h5_file_path), "Simple data type was not exported correct")

        # Generate data type group and export it to ZIP file
        self.datatype_group = self.datatypeFactory.create_datatype_group()
        _, self.zip_file_path, _ = export_manager.export_data(self.datatype_group, self.TVB_EXPORTER, self.test_project)
        self.assertTrue(os.path.exists(self.zip_file_path), "Data type group was not exported correct")

        FilesHelper().remove_project_structure(self.test_project.name)
        self.clean_database(delete_folders=False)

        # Recreate project, but a clean one where to import data
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:33,代码来源:tvb_importer_test.py

示例2: test_get_launchable_algorithms

    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)
开发者ID:gummadhav,项目名称:tvb-framework,代码行数:8,代码来源:flow_service_test.py

示例3: ObjSurfaceImporterTest

class ObjSurfaceImporterTest(TransactionalTestCase):
    """
    Unit-tests for Obj Surface importer.
    """

    torrus = os.path.join(os.path.dirname(tvb_data.obj.__file__), 'test_torus.obj')
    face = os.path.join(os.path.dirname(tvb_data.obj.__file__), 'face_surface.obj')


    def setUp(self):
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()


    def tearDown(self):
        FilesHelper().remove_project_structure(self.test_project.name)


    def _importSurface(self, import_file_path=None):
        ### Retrieve Adapter instance
        group = dao.find_group('tvb.adapters.uploaders.obj_importer', 'ObjSurfaceImporter')
        importer = ABCAdapter.build_adapter(group)

        args = {'data_file': import_file_path,
                "surface_type": FACE,
                DataTypeMetaData.KEY_SUBJECT: "John"}

        ### Launch import Operation
        FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args)

        data_types = FlowService().get_available_datatypes(self.test_project.id, FaceSurface)[0]
        self.assertEqual(1, len(data_types), "Project should contain only one data type.")

        surface = ABCAdapter.load_entity_by_gid(data_types[0][2])
        self.assertTrue(surface is not None, "Surface should not be None")
        return surface


    def test_import_quads_no_normals(self):
        """
        Test that import works with a file which contains quads and no normals
        """
        surface = self._importSurface(self.face)
        self.assertEqual(8614, len(surface.vertices))
        self.assertEqual(8614, len(surface.vertex_normals))
        self.assertEqual(17224, len(surface.triangles))


    def test_import_simple_with_normals(self):
        """
        Test that import works with an OBJ file which included normals
        """
        surface = self._importSurface(self.torrus)
        self.assertEqual(441, surface.number_of_vertices)
        self.assertEqual(441, len(surface.vertex_normals))
        self.assertEqual(800, surface.number_of_triangles)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:57,代码来源:obj_importer_test.py

示例4: EEGMonitorTest

class EEGMonitorTest(TransactionalTestCase):
    """
    Unit-tests for EEG Viewer.
    """
    def setUp(self):
        """
        Sets up the environment for running the tests;
        creates a test user, a test project, a connectivity and a surface;
        imports a CFF data-set
        """
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()
        
        TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project)
        self.connectivity = TestFactory.get_entity(self.test_project, Connectivity())
        self.assertTrue(self.connectivity is not None)

                
    def tearDown(self):
        """
        Clean-up tests data
        """
        FilesHelper().remove_project_structure(self.test_project.name)
    
    
    def test_launch(self):
        """
        Check that all required keys are present in output from BrainViewer launch.
        """
        zip_path = os.path.join(os.path.dirname(sensors_dataset.__file__), 
                                'EEG_unit_vectors_BrainProducts_62.txt.bz2')
        
        TestFactory.import_sensors(self.test_user, self.test_project, zip_path, 'EEG Sensors')
        sensors = TestFactory.get_entity(self.test_project, SensorsEEG())
        time_series = self.datatypeFactory.create_timeseries(self.connectivity, 'EEG', sensors)
        viewer = EegMonitor()
        result = viewer.launch(time_series)
        expected_keys = ['tsNames', 'groupedLabels', 'tsModes', 'tsStateVars', 'longestChannelLength',
                         'label_x', 'entities', 'page_size', 'number_of_visible_points',
                         'extended_view', 'initialSelection', 'ag_settings', 'ag_settings']

        for key in expected_keys:
            self.assertTrue(key in result, "key not found %s" % key)

        expected_ag_settings = ['channelsPerSet', 'channelLabels', 'noOfChannels', 'translationStep',
                                'normalizedSteps', 'nan_value_found', 'baseURLS', 'pageSize',
                                'nrOfPages', 'timeSetPaths', 'totalLength', 'number_of_visible_points',
                                'extended_view', 'measurePointsSelectionGIDs']

        ag_settings = json.loads(result['ag_settings'])

        for key in expected_ag_settings:
            self.assertTrue(key in ag_settings, "ag_settings should have the key %s" % key)
开发者ID:sdiazpier,项目名称:tvb-framework,代码行数:54,代码来源:eegmonitor_test.py

示例5: TestObjSurfaceImporter

class TestObjSurfaceImporter(TransactionalTestCase):
    """
    Unit-tests for Obj Surface importer.
    """

    torus = os.path.join(os.path.dirname(tvb_data.obj.__file__), 'test_torus.obj')
    face = os.path.join(os.path.dirname(tvb_data.obj.__file__), 'face_surface.obj')

    def transactional_setup_method(self):
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()

    def transactional_teardown_method(self):
        FilesHelper().remove_project_structure(self.test_project.name)

    def _import_surface(self, import_file_path=None):
        ### Retrieve Adapter instance
        importer = TestFactory.create_adapter('tvb.adapters.uploaders.obj_importer', 'ObjSurfaceImporter')

        args = {'data_file': import_file_path,
                "surface_type": FACE,
                DataTypeMetaData.KEY_SUBJECT: "John"}

        ### Launch import Operation
        FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args)

        data_types = FlowService().get_available_datatypes(self.test_project.id, FaceSurface)[0]
        assert 1, len(data_types) == "Project should contain only one data type."

        surface = ABCAdapter.load_entity_by_gid(data_types[0][2])
        assert surface is not None, "Surface should not be None"
        return surface

    def test_import_quads_no_normals(self):
        """
        Test that import works with a file which contains quads and no normals
        """
        surface = self._import_surface(self.face)
        assert 8614 == len(surface.vertices)
        assert 8614 == len(surface.vertex_normals)
        assert 17224 == len(surface.triangles)

    def test_import_simple_with_normals(self):
        """
        Test that import works with an OBJ file which included normals
        """
        surface = self._import_surface(self.torus)
        assert 441 == surface.number_of_vertices
        assert 441 == len(surface.vertex_normals)
        assert 800 == surface.number_of_triangles
开发者ID:maedoc,项目名称:tvb-framework,代码行数:51,代码来源:obj_importer_test.py

示例6: transactional_setup_method

 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
开发者ID:maedoc,项目名称:tvb-framework,代码行数:14,代码来源:surface_model_parameters_controller_test.py

示例7: transactional_setup_method

 def transactional_setup_method(self):
     """
     Sets up the environment for running the tests;
     creates a datatype group
     """
     self.datatypeFactory = DatatypesFactory()
     self.group = self.datatypeFactory.create_datatype_group()
开发者ID:maedoc,项目名称:tvb-framework,代码行数:7,代码来源:pse_test.py

示例8: setUp

 def setUp(self):
     """
     Sets up the environment for running the tests;
     creates a datatype group
     """
     self.datatypeFactory = DatatypesFactory()
     self.group = self.datatypeFactory.create_datatype_group()
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:7,代码来源:pse_test.py

示例9: ZIPSurfaceImporterTest

class ZIPSurfaceImporterTest(TransactionalTestCase):
    """
    Unit-tests for Zip Surface importer.
    """

    surf_skull = os.path.join(os.path.dirname(tvb_data.surfaceData.__file__), 'outer_skull_4096.zip')


    def setUp(self):
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()


    def tearDown(self):
        FilesHelper().remove_project_structure(self.test_project.name)


    def _importSurface(self, import_file_path=None):
        ### Retrieve Adapter instance
        group = dao.find_group('tvb.adapters.uploaders.zip_surface_importer', 'ZIPSurfaceImporter')
        importer = ABCAdapter.build_adapter(group)
        args = {
            'uploaded': import_file_path, 'surface_type': OUTER_SKULL,
            'zero_based_triangles': True,
            DataTypeMetaData.KEY_SUBJECT: "John"
        }

        ### Launch import Operation
        FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args)

        data_types = FlowService().get_available_datatypes(self.test_project.id, SkullSkin)[0]
        self.assertEqual(1, len(data_types), "Project should contain only one data type.")

        surface = ABCAdapter.load_entity_by_gid(data_types[0][2])
        self.assertTrue(surface is not None, "Surface should not be None")
        return surface


    def test_import_surf_zip(self):
        surface = self._importSurface(self.surf_skull)
        self.assertEqual(4096, len(surface.vertices))
        self.assertEqual(4096, surface.number_of_vertices)
        self.assertEqual(8188, len(surface.triangles))
        self.assertEqual(8188, surface.number_of_triangles)
        self.assertEqual('', surface.user_tag_3)
        self.assertTrue(surface.valid_for_simulations)
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:47,代码来源:zip_surface_importer_test.py

示例10: TimeSeriesTest

class TimeSeriesTest(TransactionalTestCase):
    """
    Unit-tests for Time Series Viewer.
    """

    def setUp(self):
        """
        Sets up the environment for running the tests;
        creates a test user, a test project, a connectivity and a surface;
        imports a CFF data-set
        """
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()

        TestFactory.import_cff(test_user=self.test_user, test_project=self.test_project)
        self.connectivity = TestFactory.get_entity(self.test_project, Connectivity())
        self.assertTrue(self.connectivity is not None)

    def tearDown(self):
        """
        Clean-up tests data
        """
        FilesHelper().remove_project_structure(self.test_project.name)

    def test_launch(self):
        """
        Check that all required keys are present in output from BrainViewer launch.
        """
        timeseries = self.datatypeFactory.create_timeseries(self.connectivity)
        viewer = TimeSeries()
        result = viewer.launch(timeseries)
        expected_keys = [
            "t0",
            "shape",
            "preview",
            "labelsStateVar",
            "labelsModes",
            "mainContent",
            "labels",
            "labels_json",
            "figsize",
            "dt",
        ]
        for key in expected_keys:
            self.assertTrue(key in result)
开发者ID:lcosters,项目名称:tvb-framework,代码行数:46,代码来源:time_series_test.py

示例11: MatTimeSeriesImporterTest

class MatTimeSeriesImporterTest(TransactionalTestCase):

    base_pth = os.path.join(os.path.dirname(tvb_data.__file__), 'berlinSubjects', 'QL_20120814')
    bold_path = os.path.join(base_pth, 'QL_BOLD_regiontimecourse.mat')
    connectivity_path = os.path.join(base_pth, 'QL_20120814_Connectivity.zip')

    def setUp(self):
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()
        self._import_connectivity()


    def tearDown(self):
        FilesHelper().remove_project_structure(self.test_project.name)


    def _import_connectivity(self):
        group = dao.find_group('tvb.adapters.uploaders.zip_connectivity_importer', 'ZIPConnectivityImporter')
        importer = ABCAdapter.build_adapter(group)

        ### Launch Operation
        FlowService().fire_operation(importer, self.test_user, self.test_project.id,
                                     uploaded=self.connectivity_path, Data_Subject='QL')

        self.connectivity = TestFactory.get_entity(self.test_project, Connectivity())


    def test_import_bold(self):
        ### Retrieve Adapter instance
        group = dao.find_group('tvb.adapters.uploaders.mat_timeseries_importer', 'MatTimeSeriesImporter')
        importer = ABCAdapter.build_adapter(group)

        args = dict(data_file=self.bold_path, dataset_name='QL_20120824_DK_BOLD_timecourse', structure_path='',
                    transpose=False, slice=None, sampling_rate=1000, start_time=0,
                    tstype='region',
                    tstype_parameters_option_region_connectivity=self.connectivity.gid,
                    Data_Subject="QL")

        ### Launch import Operation
        FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args)

        tsr = TestFactory.get_entity(self.test_project, TimeSeriesRegion())

        self.assertEqual((661, 1, 68, 1), tsr.read_data_shape())
开发者ID:amitsaroj001,项目名称:tvb-framework,代码行数:45,代码来源:mat_timeseries_importer_test.py

示例12: transactional_setup_method

 def transactional_setup_method(self):
     """
     Sets up the environment for running the tests;
     creates a test user, a test project and a `Sensors_Importer`
     """
     self.datatypeFactory = DatatypesFactory()
     self.test_project = self.datatypeFactory.get_project()
     self.test_user = self.datatypeFactory.get_user()
     self.importer = Sensors_Importer()
开发者ID:maedoc,项目名称:tvb-framework,代码行数:9,代码来源:sensors_importer_test.py

示例13: TestZIPSurfaceImporter

class TestZIPSurfaceImporter(TransactionalTestCase):
    """
    Unit-tests for Zip Surface importer.
    """

    surf_skull = os.path.join(os.path.dirname(tvb_data.surfaceData.__file__), 'outer_skull_4096.zip')


    def transactional_setup_method(self):
        self.datatypeFactory = DatatypesFactory()
        self.test_project = self.datatypeFactory.get_project()
        self.test_user = self.datatypeFactory.get_user()


    def transactional_teardown_method(self):
        FilesHelper().remove_project_structure(self.test_project.name)


    def _importSurface(self, import_file_path=None):
        ### Retrieve Adapter instance
        importer = TestFactory.create_adapter('tvb.adapters.uploaders.zip_surface_importer', 'ZIPSurfaceImporter')
        args = {'uploaded': import_file_path, 'surface_type': OUTER_SKULL,
                'zero_based_triangles': True,
                DataTypeMetaData.KEY_SUBJECT: "John"}

        ### Launch import Operation
        FlowService().fire_operation(importer, self.test_user, self.test_project.id, **args)

        data_types = FlowService().get_available_datatypes(self.test_project.id, SkullSkin)[0]
        assert 1, len(data_types) == "Project should contain only one data type."

        surface = ABCAdapter.load_entity_by_gid(data_types[0][2])
        assert surface is not None, "Surface should not be None"
        return surface


    def test_import_surf_zip(self):
        surface = self._importSurface(self.surf_skull)
        assert 4096 == len(surface.vertices)
        assert 4096 == surface.number_of_vertices
        assert 8188 == len(surface.triangles)
        assert 8188 == surface.number_of_triangles
        assert '' == surface.user_tag_3
        assert surface.valid_for_simulations
开发者ID:maedoc,项目名称:tvb-framework,代码行数:44,代码来源:zip_surface_importer_test.py

示例14: _BaseLinksTest

class _BaseLinksTest(TransactionalTestCase):

    GEORGE1st = "george the grey"
    GEORGE2nd = "george"


    def _initialize_two_projects(self):
        """
        Creates a user, an algorithm and 2 projects
        Project src_project will have an operation and 2 datatypes
        Project dest_project will be empty.
        Initializes a flow and a project service
        """
        self.datatype_factory_src = DatatypesFactory()
        self.src_project = self.datatype_factory_src.project
        self.src_usr_id = self.datatype_factory_src.user.id

        self.red_datatype = self.datatype_factory_src.create_simple_datatype(subject=self.GEORGE1st)
        self.blue_datatype = self.datatype_factory_src.create_datatype_with_storage(subject=self.GEORGE2nd)

        # create the destination project
        self.datatype_factory_dest = DatatypesFactory()
        self.dest_project = self.datatype_factory_dest.project
        self.dest_usr_id = self.datatype_factory_dest.user.id

        self.flow_service = FlowService()
        self.project_service = ProjectService()


    def setUp(self):
        self.clean_database(delete_folders=True)
        self._initialize_two_projects()


    def tearDown(self):
        self.clean_database(delete_folders=True)


    def red_datatypes_in(self, project_id):
        return self.flow_service.get_available_datatypes(project_id, Datatype1)[1]


    def blue_datatypes_in(self, project_id):
        return self.flow_service.get_available_datatypes(project_id, Datatype2)[1]
开发者ID:LauHoiYanGladys,项目名称:tvb-framework,代码行数:44,代码来源:links_test.py

示例15: setUpTVB

    def setUpTVB(self):
        """
        Creates a user, an algorithm and 2 projects
        Project src_project will have an operation and 2 datatypes
        Project dest_project will be empty.
        Initializes a flow and a project service
        """
        datatype_factory = DatatypesFactory()
        self.user = datatype_factory.user
        self.src_project = datatype_factory.project

        self.red_datatype = datatype_factory.create_simple_datatype(subject=self.GEORGE1st)
        self.blue_datatype = datatype_factory.create_datatype_with_storage(subject=self.GEORGE2nd)

        # create the destination project
        self.dest_project = TestFactory.create_project(admin=datatype_factory.user, name="destination")

        self.flow_service = FlowService()
        self.project_service = ProjectService()
开发者ID:unimauro,项目名称:tvb-framework,代码行数:19,代码来源:links_test.py


注:本文中的tvb.tests.framework.datatypes.datatypes_factory.DatatypesFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。