Example #1
0
    def test_cfunits_conform(self):
        vdim = VectorDimension(value=[5., 10., 15.], units='celsius')
        vdim.set_extrapolated_bounds()
        vdim.cfunits_conform(get_units_object('kelvin'))
        self.assertNumpyAll(vdim.bounds, np.array([[275.65, 280.65], [280.65, 285.65], [285.65, 290.65]]))

        # Test conforming without bounds.
        vdim = VectorDimension(value=[5., 10., 15.], units='celsius')
        vdim.cfunits_conform('kelvin')
        self.assertNumpyAll(vdim.value, np.array([278.15, 283.15, 288.15]))
Example #2
0
 def test_units_with_bounds(self):
     value = [5., 10., 15.]
     vdim = VectorDimension(value=value, units='celsius',
                            bounds=get_bounds_from_1d(np.array(value)))
     vdim.cfunits_conform(get_units_object('kelvin'))
     self.assertNumpyAll(vdim.bounds, np.array([[275.65, 280.65], [280.65, 285.65], [285.65, 290.65]]))
Example #3
0
 def test_with_units_and_bounds_interpolation(self):
     vdim = VectorDimension(value=[5., 10., 15.], units='celsius')
     vdim.set_extrapolated_bounds()
     vdim.cfunits_conform(Units('kelvin'))
     self.assertNumpyAll(vdim.bounds, np.array([[275.65, 280.65], [280.65, 285.65], [285.65, 290.65]]))
Example #4
0
 def test_with_units(self):
     vdim = VectorDimension(value=[5, 10, 15], units='celsius')
     self.assertEqual(vdim.cfunits, Units('celsius'))
     vdim.cfunits_conform(Units('kelvin'))
     self.assertNumpyAll(vdim.value, np.array([278.15, 283.15, 288.15]))