Skip to content

Commit

Permalink
formatting review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mspelman07 committed Oct 10, 2023
1 parent 30f8d34 commit 96e8638
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
6 changes: 4 additions & 2 deletions improver/utilities/cube_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,10 @@ def process(self, variable_on_levels: Cube) -> Cube:

coord_list = [coord.name() for coord in variable_on_levels.coords()]
if "height" in coord_list and "pressure" in coord_list:
raise NotImplementedError("""Input Cube has both a pressure and height coordinate.
Only one of these should be present on the cube.""")
raise NotImplementedError(
"""Input Cube has both a pressure and height coordinate.
Only one of these should be present on the cube."""
)

try:
self.coordinate = variable_on_levels.coord("pressure").name()
Expand Down
18 changes: 12 additions & 6 deletions improver_tests/utilities/cube_extraction/test_ExtractLevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

import numpy as np
import pytest
from iris.cube import Cube, CubeList
from iris.cube import Cube

from improver.synthetic_data.set_up_test_cubes import set_up_variable_cube
from improver.utilities.cube_extraction import ExtractLevel
Expand Down Expand Up @@ -269,9 +269,15 @@ def test_only_one_point(
assert not np.ma.is_masked(result.data)
np.testing.assert_array_almost_equal(result.data, expected_data)

def test_both_pressure_and_height_error(temperature_on_height_levels,temperature_on_pressure_levels):

def test_both_pressure_and_height_error(temperature_on_height_levels):
"""Tests an error is raised if both pressure and height coordinates are present
on the input cube"""
temperature_on_height_levels.coord("realization").rename("pressure")
with pytest.raises(NotImplementedError,match="Input Cube has both a pressure and height coordinate."):
ExtractLevel(
value_of_level=277, positive_correlation=True
)(temperature_on_height_levels)
with pytest.raises(
NotImplementedError,
match="Input Cube has both a pressure and height coordinate.",
):
ExtractLevel(value_of_level=277, positive_correlation=True)(
temperature_on_height_levels
)

0 comments on commit 96e8638

Please sign in to comment.