def test_nop__levels_match(self): vcoord = _make_vcoord(self.z) self.assertEqual(self.cube.coord(axis='z', dim_coords=True), vcoord) levels = vcoord.points result = extract_levels(self.cube, levels, 'linear') self.assertEqual(result, self.cube) self.assertEqual(id(result), id(self.cube))
def test_non_monotonic(self): shape = (2, 2, 1) data = np.empty(shape) levels = np.array([10, 10]) result = create_cube(self.cube, data, levels) expected = _make_cube(data, aux_coord=False, dim_coord=False) vcoord = _make_vcoord(levels) expected.add_aux_coord(vcoord, 0) self.assertEqual(result, expected)
def test_collapse(self): shape = (1, 2, 1) data = np.empty(shape) levels = np.array([123]) result = create_cube(self.cube, data, levels) expected = _make_cube(data, aux_coord=False, dim_coord=False)[0] vcoord = _make_vcoord(levels) expected.add_aux_coord(vcoord) self.assertEqual(result, expected)
def test(self): shape = (2, 2, 1) data = np.empty(shape) levels = np.array([10, 20]) result = create_cube(self.cube, data, self.cube.coord(axis='z', dim_coords=True), levels) expected = _make_cube(data, aux_coord=False, dim_coord=False) vcoord = _make_vcoord(levels) expected.add_dim_coord(vcoord, 0) self.assertEqual(result, expected)