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


Python utils.create_data_container函数代码示例

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


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

示例1: test_compare_nodes_not_equal

    def test_compare_nodes_not_equal(self):
        # given
        node = LatticeNode(
            index=(0, 2, 1),
            data=create_data_container())
        reference = LatticeNode(
            index=(1, 2, 1),
            data=create_data_container())

        # when/then
        with self.assertRaises(AssertionError):
            compare_lattice_nodes(node, reference, testcase=self)

        # given
        node = LatticeNode(
            index=(0, 2, 1),
            data=DataContainer())

        # when/then
        with self.assertRaises(AssertionError):
            compare_lattice_nodes(node, reference, testcase=self)

        # given
        node = LatticeNode((0, 0, 0))

        # when/then
        with self.assertRaises(AssertionError):
            compare_lattice_nodes(node, reference, testcase=self)
开发者ID:anshmania,项目名称:simphony-common,代码行数:28,代码来源:test_utils.py

示例2: test_add_multiple_particles_with_unsupported_cuba

    def test_add_multiple_particles_with_unsupported_cuba(self):
        # given
        container = self.container
        particles = []
        for i in xrange(10):
            data = create_data_container()
            particles.append(
                Particle([i, i*10, i*100], data=data))

        # TODO. This is a fix so particles have the right attributes
        # for lammps (MD)
        material = self.configurator.materials[0]
        for p in particles:
            p.data[CUBA.MATERIAL_TYPE] = material.uid

        # when
        container.add(particles)

        # then
        for particle in particles:
            particle.data = create_data_container(
                restrict=self.supported_cuba())

            # TODO. This is a fix so particles have the right attributes
            # for lammps (MD)
            particle.data[CUBA.MATERIAL_TYPE] = material.uid

            uid = particle.uid
            self.assertTrue(container.has(uid))
            self.assertEqual(container.get(uid), particle)
开发者ID:simphony,项目名称:simphony-lammps-md,代码行数:30,代码来源:test_particles.py

示例3: test_compare_data_containers_equal

    def test_compare_data_containers_equal(self):
        data = create_data_container()
        expected = create_data_container()

        # This should pass without a problem
        compare_data_containers(data, expected, testcase=self)
        compare_data_containers(
            DataContainer(), DataContainer(), testcase=self)
        compare_data_containers({}, DataContainer(), testcase=self)
开发者ID:anshmania,项目名称:simphony-common,代码行数:9,代码来源:test_utils.py

示例4: test_compare_data_containers_not_equal

    def test_compare_data_containers_not_equal(self):
        expected = create_data_container()

        data = create_data_container(constant=1)
        with self.assertRaises(AssertionError):
            compare_data_containers(data, expected, testcase=self)

        data = create_data_container(restrict=[CUBA.MASS])
        with self.assertRaises(AssertionError):
            compare_data_containers(data, expected, testcase=self)
开发者ID:anshmania,项目名称:simphony-common,代码行数:10,代码来源:test_utils.py

示例5: test_accumulate_with_empty_keys

    def test_accumulate_with_empty_keys(self):
        accumulator = CUBADataAccumulator([])
        accumulator.append(create_data_container(restrict=[CUBA.NAME]))
        accumulator.append(
            create_data_container(restrict=[CUBA.NAME, CUBA.VELOCITY,
                                            CUBA.LATTICE_VECTORS]))

        self.assertEqual(len(accumulator.keys), 0)
        vtk_data = tvtk.PointData()
        accumulator.load_onto_vtk(vtk_data)
        self.assertEqual(vtk_data.number_of_arrays, 0)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:11,代码来源:test_cuba_data_accumulator.py

示例6: test_container_data_update_with_unsupported_cuba

    def test_container_data_update_with_unsupported_cuba(self):
        # given
        container = self.container
        data = create_data_container()
        expected_data = create_data_container(restrict=self.supported_cuba())

        # when
        container.data = data

        # then
        self.assertEqual(container.data, expected_data)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:11,代码来源:abc_check_particles.py

示例7: test_compare_nodes_equal

    def test_compare_nodes_equal(self):
        # given
        node = LatticeNode(
            index=(0, 2, 1),
            data=create_data_container())
        reference = LatticeNode(
            index=(0, 2, 1),
            data=create_data_container())

        # this should pass without problems
        compare_lattice_nodes(node, reference, testcase=self)
开发者ID:anshmania,项目名称:simphony-common,代码行数:11,代码来源:test_utils.py

示例8: test_compare_points_equal

    def test_compare_points_equal(self):
        # given
        point = Point(
            uid=None,
            coordinates=(10.0, 0.0, 2.0),
            data=create_data_container())
        reference = Point(
            uid=None,
            coordinates=(10.0, 0.0, 2.0),
            data=create_data_container())

        # this should pass without problems
        compare_points(point, reference, testcase=self)
开发者ID:anshmania,项目名称:simphony-common,代码行数:13,代码来源:test_utils.py

示例9: test_add_item_with_unsuported_cuba

    def test_add_item_with_unsuported_cuba(self):
        # given
        container = self.container
        expected = self.create_item(None)
        expected.data = create_data_container()

        # when
        uid = self.add_operation(container, [expected])

        # then
        retrieved = self.get_operation(container, uid[0])
        expected.data = create_data_container(restrict=self.supported_cuba())
        self.assertEqual(retrieved, expected)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:13,代码来源:abc_check_mesh.py

示例10: test_add_particles_with_unsupported_cuba

    def test_add_particles_with_unsupported_cuba(self):
        # given
        container = self.container
        particle = Particle(coordinates=(1, 2, -3), data=create_data_container())

        # when
        uids = container.add_particles([particle])
        uid = uids[0]

        # then
        particle.data = create_data_container(restrict=self.supported_cuba())
        self.assertTrue(container.has_particle(uid))
        self.assertEqual(container.get_particle(uid), particle)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:13,代码来源:abc_check_particles.py

示例11: test_load_scalars_onto_vtk

    def test_load_scalars_onto_vtk(self):
        accumulator = CUBADataAccumulator()
        accumulator.append(create_data_container(restrict=[CUBA.NAME]))
        accumulator.append(
            create_data_container(restrict=[CUBA.NAME, CUBA.TEMPERATURE]))

        vtk_data = tvtk.PointData()
        accumulator.load_onto_vtk(vtk_data)
        self.assertEqual(vtk_data.number_of_arrays, 1)
        expected = numpy.array(
            [None, dummy_cuba_value(CUBA.TEMPERATURE)], dtype=float)
        assert_array_equal(vtk_data.get_array(0), expected)
        assert_array_equal(vtk_data.get_array(CUBA.TEMPERATURE.name), expected)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:13,代码来源:test_cuba_data_accumulator.py

示例12: test_compare_bonds_equal

    def test_compare_bonds_equal(self):
        # given
        particles = [uuid.uuid4(), uuid.uuid4()],
        bond = Bond(
            uid=None,
            particles=particles,
            data=create_data_container())
        reference = Bond(
            uid=None,
            particles=particles,
            data=create_data_container())

        # this should pass without problems
        compare_bonds(bond, reference, testcase=self)
开发者ID:anshmania,项目名称:simphony-common,代码行数:14,代码来源:test_utils.py

示例13: test_accumulate_and_expand

    def test_accumulate_and_expand(self):
        accumulator = CUBADataAccumulator()
        accumulator.append(create_data_container(restrict=[CUBA.NAME]))
        accumulator.append(
            create_data_container(restrict=[CUBA.NAME, CUBA.TEMPERATURE]))

        self.assertEqual(len(accumulator), 2)
        self.assertEqual(accumulator.keys, set([CUBA.NAME, CUBA.TEMPERATURE]))
        assert_array_equal(
            accumulator[CUBA.TEMPERATURE],
            [None, dummy_cuba_value(CUBA.TEMPERATURE)])
        assert_array_equal(
            accumulator[CUBA.NAME],
            [dummy_cuba_value(CUBA.NAME)] * 2)
开发者ID:simphony,项目名称:simphony-mayavi,代码行数:14,代码来源:test_cuba_data_accumulator.py

示例14: test_update_item_with_unsuported_cuba

    def test_update_item_with_unsuported_cuba(self):
        # given
        container = self.container
        uids = self._add_items(container)
        item = self.get_operation(container, uids[2])
        item.data = create_data_container()

        # when
        self.update_operation(container, [item])

        # then
        retrieved = self.get_operation(container, item.uid)
        item.data = create_data_container(restrict=self.supported_cuba())
        self.assertEqual(retrieved, item)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:14,代码来源:abc_check_mesh.py

示例15: test_add_bonds_with_unsupported_cuba

    def test_add_bonds_with_unsupported_cuba(self):
        # given
        container = self.container
        particles = self.particle_list[0].uid, self.particle_list[-1].uid
        bond = Bond(particles=particles, data=create_data_container())

        # when
        uids = container.add_bonds([bond])
        uid = uids[0]

        # then
        bond.data = create_data_container(restrict=self.supported_cuba())
        self.assertTrue(container.has_bond(uid))
        self.assertEqual(container.get_bond(uid), bond)
开发者ID:kitchoi,项目名称:simphony-common,代码行数:14,代码来源:abc_check_particles.py


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