From 96621621730fe1e28c898fe8aee7d053f75036eb Mon Sep 17 00:00:00 2001 From: Morgan Williams Date: Fri, 17 May 2024 10:39:29 +1000 Subject: [PATCH] Add teardown for util.classification plotting tests --- test/util/util_classification.py | 33 ++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/test/util/util_classification.py b/test/util/util_classification.py index 16d71694..6c026bd4 100644 --- a/test/util/util_classification.py +++ b/test/util/util_classification.py @@ -1,13 +1,16 @@ import unittest + import matplotlib.pyplot as plt import pandas as pd -from pyrolite.util.classification import (TAS, - USDASoilTexture, - QAP, - FeldsparTernary, - JensenPlot, - PeralkalinityClassifier) +from pyrolite.util.classification import ( + QAP, + TAS, + FeldsparTernary, + JensenPlot, + PeralkalinityClassifier, + USDASoilTexture, +) from pyrolite.util.synthetic import normal_frame, random_cov_matrix @@ -50,6 +53,9 @@ def test_classifer_predict(self): _ = classes.apply(lambda x: cm.fields.get(x, {"name": None})["name"]) self.assertFalse(pd.isnull(classes).all()) + def tearDown(self): + plt.close("all") + class TestUSDASoilTexture(unittest.TestCase): def setUp(self): @@ -77,6 +83,9 @@ def test_classifer_predict(self): classes = cm.predict(df, data_scale=1.0) self.assertFalse(pd.isnull(classes).all()) + def tearDown(self): + plt.close("all") + class TestQAP(unittest.TestCase): def setUp(self): @@ -104,6 +113,9 @@ def test_classifer_predict(self): classes = cm.predict(df) self.assertFalse(pd.isnull(classes).all()) + def tearDown(self): + plt.close("all") + class TestFeldsparTernary(unittest.TestCase): def setUp(self): @@ -131,6 +143,9 @@ def test_classifer_predict(self): classes = cm.predict(df) self.assertFalse(pd.isnull(classes).all()) + def tearDown(self): + plt.close("all") + class TestJensenPlot(unittest.TestCase): def setUp(self): @@ -159,6 +174,9 @@ def test_classifer_predict(self): classes = cm.predict(df) self.assertFalse(pd.isnull(classes).all()) + def tearDown(self): + plt.close("all") + class TestPeralkalinity(unittest.TestCase): """Test the peralkalinity classifier.""" @@ -175,6 +193,9 @@ def test_classifer_predict(self): cm = PeralkalinityClassifier() df.loc[:, "Peralk"] = cm.predict(df) + def tearDown(self): + plt.close("all") + if __name__ == "__main__": unittest.main()