예제 #1
0
 def setUp(self):
     mesh = sample_mesh()
     self.mesh = mesh
     self.meshcoord = sample_meshcoord(mesh=mesh)
예제 #2
0
 def test_fail_slice_part(self):
     meshcoord = sample_meshcoord()
     with self.assertRaisesRegex(ValueError, "Cannot index"):
         meshcoord[:1]
예제 #3
0
 def setUp(self):
     mesh = sample_mesh()
     self.mesh = mesh
     # Give mesh itself a name: makes a difference between str and repr.
     self.mesh.rename("test_mesh")
     self.meshcoord = sample_meshcoord(mesh=mesh)
예제 #4
0
 def test_fail_copy_newbounds(self):
     meshcoord = sample_meshcoord()
     with self.assertRaisesRegex(ValueError, "Cannot change the content"):
         meshcoord.copy(bounds=meshcoord.bounds)
예제 #5
0
 def test_slice_whole_slice_singlekey(self):
     # A slice(None) also fails, if not presented in a 1-tuple.
     meshcoord = sample_meshcoord()
     with self.assertRaisesRegex(ValueError, "Cannot index"):
         meshcoord[:]
예제 #6
0
 def _create_common_mesh(self, **kwargs):
     return sample_meshcoord(mesh=self.mesh, **kwargs)
예제 #7
0
 def test_equal_mesh(self):
     mesh1 = sample_mesh()
     mesh2 = sample_mesh()
     meshcoord1 = sample_meshcoord(mesh=mesh1)
     meshcoord2 = sample_meshcoord(mesh=mesh2)
     self.assertEqual(meshcoord2, meshcoord1)
예제 #8
0
 def test_fail_bad_axis(self):
     with self.assertRaisesRegex(ValueError, "not a valid Mesh axis"):
         sample_meshcoord(axis="q")
예제 #9
0
 def setUp(self):
     self.meshcoord = sample_meshcoord()
예제 #10
0
 def test_fail_bad_location(self):
     with self.assertRaisesRegex(ValueError, "not a valid Mesh location"):
         sample_meshcoord(location="bad")
예제 #11
0
 def test_valid_locations(self):
     for loc in Mesh.LOCATIONS:
         meshcoord = sample_meshcoord(location=loc)
         self.assertEqual(meshcoord.location, loc)
예제 #12
0
 def test_fail_bad_mesh(self):
     with self.assertRaisesRegex(TypeError, "must be a.*Mesh"):
         sample_meshcoord(mesh=mock.sentinel.odd)
예제 #13
0
 def test_alternative_location_and_axis(self):
     meshcoord = sample_meshcoord(mesh=self.mesh, location="edge", axis="y")
     result = str(meshcoord)
     re_expected = r", location='edge', axis='y'"
     self.assertRegex(result, re_expected)
예제 #14
0
 def test_node(self):
     meshcoord = sample_meshcoord(location="node")
     n_nodes = (iris.tests.stock.mesh._TEST_N_NODES
                )  # n-nodes default for sample mesh
     self.assertIsNone(meshcoord.core_bounds())
     self.assertArrayAllClose(meshcoord.points, 1100 + np.arange(n_nodes))