예제 #1
0
 def test6(self):
     particles = Particles(2)
     particles.add_attribute_domain('a')
     particles.add_attribute_domain('b')
     def set_a():
         particles[0].a = 1 | units.kg
     self.assertRaises(AttributeError, set_a)
예제 #2
0
    def test6(self):
        particles = Particles(2)
        particles.add_attribute_domain('a')
        particles.add_attribute_domain('b')

        def set_a():
            particles[0].a = 1 | units.kg

        self.assertRaises(AttributeError, set_a)
예제 #3
0
 def test1(self):
     particles = Particles(2)
     particles.add_attribute_domain('a')
     particles.add_attribute_domain('b')
     particles.a.foo = 1 | units.m
     particles.b.foo = 2 | units.kg
     particles.foo = 3 | units.s
     
     self.assertAlmostRelativeEqual(particles.a.foo,  1 | units.m)
     self.assertAlmostRelativeEqual(particles.b.foo,  2 | units.kg)
     self.assertAlmostRelativeEqual(particles.foo,  3 | units.s)
예제 #4
0
    def test1(self):
        particles = Particles(2)
        particles.add_attribute_domain('a')
        particles.add_attribute_domain('b')
        particles.a.foo = 1 | units.m
        particles.b.foo = 2 | units.kg
        particles.foo = 3 | units.s

        self.assertAlmostRelativeEqual(particles.a.foo, 1 | units.m)
        self.assertAlmostRelativeEqual(particles.b.foo, 2 | units.kg)
        self.assertAlmostRelativeEqual(particles.foo, 3 | units.s)
예제 #5
0
 def test2(self):
     particles = Particles(2)
     particles.add_attribute_domain('a')
     particles.add_attribute_domain('b')
     particles.a.foo = 1 | units.m
     particles.b.bar = 2 | units.kg
     particles.foo = 3 | units.s
     self.assertEquals(
         sorted(particles.a.get_attribute_names_defined_in_store()),
         ['foo'])
     self.assertEquals(
         sorted(particles.b.get_attribute_names_defined_in_store()),
         ['bar'])
예제 #6
0
 def test2(self):
     particles = Particles(2)
     particles.add_attribute_domain('a')
     particles.add_attribute_domain('b')
     particles.a.foo = 1 | units.m
     particles.b.bar = 2 | units.kg
     particles.foo = 3 | units.s
     self.assertEquals(
         sorted(particles.a.get_attribute_names_defined_in_store()), 
         ['foo']
     )
     self.assertEquals(
         sorted(particles.b.get_attribute_names_defined_in_store()), 
         ['bar']
     )
예제 #7
0
 def test5(self):
     particles = Particles(2)
     particles.add_attribute_domain('a')
     particles.add_attribute_domain('b')
     particles.a.foo = 1 | units.m
     particles.b.foo = 2 | units.kg
     particles.foo = 3 | units.s
     
     particles.a[0].foo = 3 | units.m
     
     self.assertAlmostRelativeEqual(particles.a.foo,  [3,1] | units.m)
     
     particles[0].a.foo = 4 | units.m
     
     self.assertAlmostRelativeEqual(particles.a.foo,  [4,1] | units.m)
     self.assertAlmostRelativeEqual(particles.b.foo,  [2,2] | units.kg)
     self.assertAlmostRelativeEqual(particles.foo,  [3,3] | units.s)
예제 #8
0
 def test3(self):
     particles = Particles(2)
     particles.add_attribute_domain('a')
     particles.add_attribute_domain('b')
     particles.a.foo = 1 | units.m
     particles.b.foo = 2 | units.kg
     particles.foo = 3 | units.s
     particles.a.add_particle(Particle(foo = 2 | units.m))
     
     self.assertAlmostRelativeEqual(particles.a.foo,  [1,1,2] | units.m)
     self.assertAlmostRelativeEqual(particles.b.foo,  [2,2,0] | units.kg)
     self.assertAlmostRelativeEqual(particles.foo,  [3,3,0] | units.s)
     
     particles.add_particle(Particle(foo = 2 | units.s))
     self.assertAlmostRelativeEqual(particles.a.foo,  [1,1,2,0] | units.m)
     self.assertAlmostRelativeEqual(particles.b.foo,  [2,2,0,0] | units.kg)
     self.assertAlmostRelativeEqual(particles.foo,  [3,3,0,2] | units.s)
예제 #9
0
    def test5(self):
        particles = Particles(2)
        particles.add_attribute_domain('a')
        particles.add_attribute_domain('b')
        particles.a.foo = 1 | units.m
        particles.b.foo = 2 | units.kg
        particles.foo = 3 | units.s

        particles.a[0].foo = 3 | units.m

        self.assertAlmostRelativeEqual(particles.a.foo, [3, 1] | units.m)

        particles[0].a.foo = 4 | units.m

        self.assertAlmostRelativeEqual(particles.a.foo, [4, 1] | units.m)
        self.assertAlmostRelativeEqual(particles.b.foo, [2, 2] | units.kg)
        self.assertAlmostRelativeEqual(particles.foo, [3, 3] | units.s)
예제 #10
0
    def test3(self):
        particles = Particles(2)
        particles.add_attribute_domain('a')
        particles.add_attribute_domain('b')
        particles.a.foo = 1 | units.m
        particles.b.foo = 2 | units.kg
        particles.foo = 3 | units.s
        particles.a.add_particle(Particle(foo=2 | units.m))

        self.assertAlmostRelativeEqual(particles.a.foo, [1, 1, 2] | units.m)
        self.assertAlmostRelativeEqual(particles.b.foo, [2, 2, 0] | units.kg)
        self.assertAlmostRelativeEqual(particles.foo, [3, 3, 0] | units.s)

        particles.add_particle(Particle(foo=2 | units.s))
        self.assertAlmostRelativeEqual(particles.a.foo, [1, 1, 2, 0] | units.m)
        self.assertAlmostRelativeEqual(particles.b.foo,
                                       [2, 2, 0, 0] | units.kg)
        self.assertAlmostRelativeEqual(particles.foo, [3, 3, 0, 2] | units.s)