Example #1
0
 def test_one_array(self):
     """ Does it pass a an array through correctly?
     """
     units = [None]
     a = array((1, 2, 3))
     result = set_units(units, a)
     self.assertTrue(all(a == result))
 def test_one_array(self):
     """ Does it pass a an array through correctly?
     """
     units = [None]
     a = array((1, 2, 3))
     result = set_units(units, a)
     self.assertTrue(all(a == result))
 def test_set_unit_overwrite_unit_array(self):
     """ Does it overwrite units on a UnitArray correctly?
     """
     units = [feet]
     a = UnitArray((1, 2, 3), units=meters)
     aa = set_units(units, a)
     self.assertTrue(all(a == aa))
     self.assertEqual(aa.units, feet)
 def test_set_scalar_with_units(self):
     """ Does it add units to a scalar correctly?
     """
     units = [feet]
     x = 3.0
     xx = set_units(units, x)
     self.assertEqual(float(xx), x)
     self.assertEqual(xx.units, feet)
Example #5
0
 def test_set_unit_overwrite_unit_array(self):
     """ Does it overwrite units on a UnitArray correctly?
     """
     units = [feet]
     a = UnitArray((1, 2, 3), units=meters)
     aa = set_units(units, a)
     self.assertTrue(all(a == aa))
     self.assertEqual(aa.units, feet)
Example #6
0
 def test_set_scalar_with_units(self):
     """ Does it add units to a scalar correctly?
     """
     units = [feet]
     x = 3.0
     xx = set_units(units, x)
     self.assertEqual(float(xx), x)
     self.assertEqual(xx.units, feet)
    def test_set_array_with_units(self):
        """ Does it add units to an array correctly?

            fixme: This may be exactly what we don't want to happen!
        """
        units = [feet]
        a = array((1, 2, 3))
        aa = set_units(units, a)
        self.assertTrue(all(a == aa))
        self.assertEqual(aa.units, feet)
Example #8
0
    def test_set_array_with_units(self):
        """ Does it add units to an array correctly?

            fixme: This may be exactly what we don't want to happen!
        """
        units = [feet]
        a = array((1, 2, 3))
        aa = set_units(units, a)
        self.assertTrue(all(a == aa))
        self.assertEqual(aa.units, feet)
    def test_set_zero_dim_array_with_units(self):
        """ Does it add units to an array with shape () correctly?

            fixme: This may be exactly what we don't want to happen!
        """
        units = [feet]
        a = array(2)
        aa = set_units(units, a)
        self.assertTrue(all(a == aa))
        self.assertEqual(aa.units, feet)
        assert isinstance(aa, UnitScalar)
Example #10
0
    def test_set_zero_dim_array_with_units(self):
        """ Does it add units to an array with shape () correctly?

            fixme: This may be exactly what we don't want to happen!
        """
        units = [feet]
        a = array(2)
        aa = set_units(units, a)
        self.assertTrue(all(a == aa))
        self.assertEqual(aa.units, feet)
        assert isinstance(aa, UnitScalar)
 def test_set_unit_overwrite_unit_scalar(self):
     """ Does it overwrite units on a UnitScalar correctly?
     """
     units = [feet]
     x = UnitScalar(3., units=meters)
     xx = set_units(units, x)
     # FIXME:
     #     Behaves very stangely (on my machine), somethimes it fails,
     #     other times it works almost like a random generator.
     #
     # We found that set_units(units, x) has a sideffect on x which it
     # should not have.
     #
     #self.assertEqual(x, xx)
     # print x, x.units
     self.assertEqual(xx.units, feet)
Example #12
0
 def test_set_unit_overwrite_unit_scalar(self):
     """ Does it overwrite units on a UnitScalar correctly?
     """
     units = [feet]
     x = UnitScalar(3., units=meters)
     xx = set_units(units, x)
     # FIXME:
     #     Behaves very stangely (on my machine), somethimes it fails,
     #     other times it works almost like a random generator.
     #
     # We found that set_units(units, x) has a sideffect on x which it
     # should not have.
     #
     #self.assertEqual(x, xx)
     #print x, x.units
     self.assertEqual(xx.units, feet)
 def test_single_float(self):
     """ Does it pass a single value through correctly?
     """
     units = [None]
     result = set_units(units, 1.0)
     self.assertEqual(1.0, result)
Example #14
0
 def test_single_float(self):
     """ Does it pass a single value through correctly?
     """
     units = [None]
     result = set_units(units, 1.0)
     self.assertEqual(1.0, result)