def setUp(self): mesh = sample_mesh() self.mesh = mesh self.meshcoord = sample_meshcoord(mesh=mesh)
def test_fail_slice_part(self): meshcoord = sample_meshcoord() with self.assertRaisesRegex(ValueError, "Cannot index"): meshcoord[:1]
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)
def test_fail_copy_newbounds(self): meshcoord = sample_meshcoord() with self.assertRaisesRegex(ValueError, "Cannot change the content"): meshcoord.copy(bounds=meshcoord.bounds)
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[:]
def _create_common_mesh(self, **kwargs): return sample_meshcoord(mesh=self.mesh, **kwargs)
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)
def test_fail_bad_axis(self): with self.assertRaisesRegex(ValueError, "not a valid Mesh axis"): sample_meshcoord(axis="q")
def setUp(self): self.meshcoord = sample_meshcoord()
def test_fail_bad_location(self): with self.assertRaisesRegex(ValueError, "not a valid Mesh location"): sample_meshcoord(location="bad")
def test_valid_locations(self): for loc in Mesh.LOCATIONS: meshcoord = sample_meshcoord(location=loc) self.assertEqual(meshcoord.location, loc)
def test_fail_bad_mesh(self): with self.assertRaisesRegex(TypeError, "must be a.*Mesh"): sample_meshcoord(mesh=mock.sentinel.odd)
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)
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))