Skip to content

Commit

Permalink
Demonstrate new check_graphic in test_plot.
Browse files Browse the repository at this point in the history
  • Loading branch information
trexfeathers committed Mar 13, 2024
1 parent 5fbcd53 commit 7c4f700
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions lib/iris/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import cf_units
import numpy as np
import pytest

import iris
import iris.analysis
Expand Down Expand Up @@ -240,14 +241,15 @@ def setUp(self):

@tests.skip_data
@tests.skip_plot
class Test1dScatter(tests.GraphicsTest):
def setUp(self):
super().setUp()
class Test1dScatter:
@pytest.fixture(autouse=True)
def setup(self, check_graphic_caller):
self.cube = iris.load_cube(
tests.get_data_path(("NAME", "NAMEIII_trajectory.txt")),
"Temperature",
)
self.draw_method = iplt.scatter
self.check_graphic = check_graphic_caller

def test_coord_coord(self):
x = self.cube.coord("longitude")
Expand Down Expand Up @@ -288,27 +290,6 @@ def test_cube_cube(self):
self.draw_method(x, y, c=c, edgecolor="none")
self.check_graphic()

def test_incompatible_objects(self):
# cubes/coordinates of different sizes cannot be plotted
x = self.cube
y = self.cube.coord("altitude")[:-1]
with self.assertRaises(ValueError):
self.draw_method(x, y)

def test_multidimensional(self):
# multidimensional cubes/coordinates are not allowed
x = _load_4d_testcube()[0, :, :, 0]
y = x.coord("model_level_number")
with self.assertRaises(ValueError):
self.draw_method(x, y)

def test_not_cube_or_coord(self):
# inputs must be cubes or coordinates
x = np.arange(self.cube.shape[0])
y = self.cube
with self.assertRaises(TypeError):
self.draw_method(x, y)


@tests.skip_data
@tests.skip_plot
Expand Down

0 comments on commit 7c4f700

Please sign in to comment.