def setUp(self):
     self.addTypeEqualityFunc(Bond, partial(compare_bonds, testcase=self))
     self.particle_list = create_particles(restrict=self.supported_cuba())
     self.container = self.container_factory("foo")
     self.container.add_particles(self.particle_list)
     self.bond_list = create_bonds(restrict=self.supported_cuba(), particles=self.particle_list)
     self.ids = self.container.add_bonds(self.bond_list)
 def setUp(self):
     self.addTypeEqualityFunc(Particle, partial(compare_particles, testcase=self))
     self.maxDiff = None
     self.particle_list = create_particles(restrict=self.supported_cuba())
     self.particle_list[0].uid = uuid.uuid4()
     self.container = self.container_factory("foo")
     self.ids = self.container.add_particles(self.particle_list)
Esempio n. 3
0
 def test_create_particles(self):
     particles = create_particles(n=10)
     self.assertEqual(len(particles), 10)
     for index, particle in enumerate(particles):
         self.assertIsInstance(particle, Particle)
         self.assertIsNone(particle.uid)
         self.assertEqual(
             particle.coordinates, (index, index*10, index*100))
         compare_data_containers(
             particle.data, create_data_container(constant=index),
             testcase=self)
Esempio n. 4
0
 def test_create_particles(self):
     particles = create_particles(n=10)
     self.assertEqual(len(particles), 10)
     for index, particle in enumerate(particles):
         self.assertIsInstance(particle, Particle)
         self.assertIsNone(particle.uid)
         self.assertEqual(particle.coordinates,
                          (index, index * 10, index * 100))
         compare_data_containers(particle.data,
                                 create_data_container(constant=index),
                                 testcase=self)
Esempio n. 5
0
 def test_create_bonds_with_particles(self):
     n = 7
     particles = create_particles(n=100)
     for particle in particles:
         particle.uid = uuid.uuid4()
     bonds = create_bonds(n=n, particles=particles)
     uids = set()
     self.assertEqual(len(bonds), n)
     for index, bond in enumerate(bonds):
         self.assertIsInstance(bond, Bond)
         compare_data_containers(
             bond.data, create_data_container(constant=index),
             testcase=self)
         self.assertEqual(len(bond.particles), n)
         uids.update(bond.particles)
     self.assertLessEqual(len(uids), n**2)
Esempio n. 6
0
 def test_create_bonds_with_particles(self):
     n = 7
     particles = create_particles(n=100)
     for particle in particles:
         particle.uid = uuid.uuid4()
     bonds = create_bonds(n=n, particles=particles)
     uids = set()
     self.assertEqual(len(bonds), n)
     for index, bond in enumerate(bonds):
         self.assertIsInstance(bond, Bond)
         compare_data_containers(bond.data,
                                 create_data_container(constant=index),
                                 testcase=self)
         self.assertEqual(len(bond.particles), n)
         uids.update(bond.particles)
     self.assertLessEqual(len(uids), n**2)
    def test_exception_when_update_multiple_particles_when_wrong_id(self):
        # given
        container = self.container
        particles = create_particles()

        # then
        with self.assertRaises(ValueError):
            # when
            container.update_particles(particles)

        # given
        particles = create_particles_with_id()

        # then
        with self.assertRaises(ValueError):
            # when
            container.update_particles(particles)
    def setUp(self):
        self.configurator = MDExampleConfigurator()
        self.wrapper = LammpsWrapper(use_internal_interface=True)
        self.configurator.configure_wrapper(self.wrapper)

        # Instead of calling CheckManipulatingParticles.setUp(self), we do the
        # same steps and also ensure the created particles have a data with
        # correct attributes (and values) for MD. Specifically, we use
        # a correct material uid.
        self.addTypeEqualityFunc(
            Particle, partial(compare_particles, testcase=self))
        self.particle_list = create_particles(restrict=self.supported_cuba())
        material = self.configurator.materials[0]
        for p in self.particle_list:
            p.data[CUBA.MATERIAL_TYPE] = material.uid

        self.container = self.container_factory('foo')
        self.ids = self.container.add(self.particle_list)