Skip to content

Commit 8fa0cdb

Browse files
committed
added classification enums to qp
1 parent 010389c commit 8fa0cdb

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/iris/quickplot.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
automatically add a plot title, axis titles, and a colour bar when appropriate.
99
1010
These also have the optional kwarg ``footer``, which adds text to the bottom right of
11-
the plot figure.
11+
the plot figure. For security classifications, the enum :class:`Classifications`
12+
can be used for common usages.
1213
1314
See also: :ref:`matplotlib <matplotlib:users-guide-index>`.
1415
1516
"""
1617

18+
from enum import StrEnum
19+
1720
import cf_units
1821
from matplotlib import patheffects
1922
import matplotlib.pyplot as plt
@@ -23,6 +26,13 @@
2326
import iris.plot as iplt
2427

2528

29+
class Classification(StrEnum):
30+
official = "Official"
31+
official_sensitive = "Official-Sensitive"
32+
secret = "Secret"
33+
top_secret = "Top Secret"
34+
35+
2636
def _use_symbol(units):
2737
# For non-time units use the shortest unit representation.
2838
# E.g. prefer 'K' over 'kelvin', but not '0.0174532925199433 rad'

lib/iris/tests/test_quickplot.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,11 @@ def test_vertical(self):
283283

284284
@_shared_utils.skip_plot
285285
class TestFooter:
286-
def test__footer(self):
287-
text = "Example"
286+
@pytest.mark.parametrize(
287+
"text", [qplt.Classification.official_sensitive, "Example"]
288+
)
289+
def test__footer(self, text):
290+
fig = plt.figure()
288291
qplt._footer(text)
289-
fig = plt.gcf()
290292
footer_text = fig.texts[0].get_text()
291293
assert text == footer_text

0 commit comments

Comments
 (0)