예제 #1
0
 def test_promote_c_and_s_units_unknown_to_dimensionless(self):
     c = mock.Mock(units=Unit("unknown"), nbounds=0)
     s = mock.Mock(units=Unit("unknown"), nbounds=0)
     self.kwargs["c"] = c
     self.kwargs["s"] = s
     factory = OceanSg1Factory(**self.kwargs)
     self.assertEqual("1", factory.dependencies["c"].units)
     self.assertEqual("1", factory.dependencies["s"].units)
예제 #2
0
 def setUp(self):
     self.s = mock.Mock(units=Unit('1'), nbounds=0)
     self.c = mock.Mock(units=Unit('1'), nbounds=0, shape=(1,))
     self.eta = mock.Mock(units=Unit('m'), nbounds=0)
     self.depth = mock.Mock(units=Unit('m'), nbounds=0)
     self.depth_c = mock.Mock(units=Unit('m'), nbounds=0, shape=(1,))
     self.kwargs = dict(s=self.s, c=self.c, eta=self.eta,
                        depth=self.depth, depth_c=self.depth_c)
     self.factory = OceanSg1Factory(**self.kwargs)
예제 #3
0
 def test_insufficient_coordinates(self):
     with self.assertRaises(ValueError):
         OceanSg1Factory()
     with self.assertRaises(ValueError):
         OceanSg1Factory(s=None,
                         c=self.c,
                         eta=self.eta,
                         depth=self.depth,
                         depth_c=self.depth_c)
     with self.assertRaises(ValueError):
         OceanSg1Factory(s=self.s,
                         c=None,
                         eta=self.eta,
                         depth=self.depth,
                         depth_c=self.depth_c)
     with self.assertRaises(ValueError):
         OceanSg1Factory(s=self.s,
                         c=self.c,
                         eta=None,
                         depth=self.depth,
                         depth_c=self.depth_c)
     with self.assertRaises(ValueError):
         OceanSg1Factory(s=self.s,
                         c=self.c,
                         eta=self.eta,
                         depth=None,
                         depth_c=self.depth_c)
     with self.assertRaises(ValueError):
         OceanSg1Factory(s=self.s,
                         c=self.c,
                         eta=self.eta,
                         depth=self.depth,
                         depth_c=None)
예제 #4
0
 def test_derived_points(self):
     # Broadcast expected points given the known dimensional mapping.
     s = self.s.points[..., np.newaxis, np.newaxis]
     c = self.c.points[..., np.newaxis, np.newaxis]
     eta = self.eta.points[np.newaxis, ...]
     depth = self.depth.points[np.newaxis, ...]
     depth_c = self.depth_c.points
     # Calculate the expected result.
     expected_coord = self.derive(s, c, eta, depth, depth_c)
     # Calculate the actual result.
     factory = OceanSg1Factory(**self.kwargs)
     coord = factory.make_coord(self.coord_dims)
     self.assertEqual(expected_coord, coord)
예제 #5
0
 def test_s_incompatible_units(self):
     self.s.units = Unit("km")
     with self.assertRaises(ValueError):
         OceanSg1Factory(**self.kwargs)
예제 #6
0
 def test_depth_c_non_scalar(self):
     self.depth_c.shape = (2, )
     with self.assertRaises(ValueError):
         OceanSg1Factory(**self.kwargs)
예제 #7
0
 def test_c_too_many_bounds(self):
     self.c.nbounds = 4
     with self.assertRaises(ValueError):
         OceanSg1Factory(**self.kwargs)
예제 #8
0
 def test_values(self):
     factory = OceanSg1Factory(**self.kwargs)
     self.assertEqual(factory.dependencies, self.kwargs)
예제 #9
0
 def test_eta_incompatible_units(self):
     self.eta.units = Unit('km')
     with self.assertRaises(ValueError):
         OceanSg1Factory(**self.kwargs)