Commit 4eace612 authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[TESTS][IMPORTANT] deactivate SCM study tests to speed up tests.

parent 873cb9a4
No related merge requests found
Showing with 86 additions and 85 deletions
+86 -85
...@@ -10,88 +10,89 @@ from experiment.meteo_france_SCM_study.safran.safran import SafranSnowfall, Exte ...@@ -10,88 +10,89 @@ from experiment.meteo_france_SCM_study.safran.safran import SafranSnowfall, Exte
from experiment.meteo_france_SCM_study.visualization.study_visualization.study_visualizer import StudyVisualizer from experiment.meteo_france_SCM_study.visualization.study_visualization.study_visualizer import StudyVisualizer
from test.test_utils import load_scm_studies from test.test_utils import load_scm_studies
# TESTS TO REACTIVATE SOMETIMES
class TestSCMAllStudy(unittest.TestCase): #
# class TestSCMAllStudy(unittest.TestCase):
def test_extended_run(self): #
for study_class in [ExtendedSafranSnowfall]: # def test_extended_run(self):
for study in study_iterator(study_class, only_first_one=True, both_altitude=False, verbose=False): # for study_class in [ExtendedSafranSnowfall]:
study_visualizer = StudyVisualizer(study, show=False, save_to_file=False) # for study in study_iterator(study_class, only_first_one=True, both_altitude=False, verbose=False):
study_visualizer.visualize_all_mean_and_max_graphs() # study_visualizer = StudyVisualizer(study, show=False, save_to_file=False)
self.assertTrue(True) # study_visualizer.visualize_all_mean_and_max_graphs()
# self.assertTrue(True)
def test_scm_daily_data(self): #
for study in load_scm_studies(): # def test_scm_daily_data(self):
time_serie = study.year_to_daily_time_serie_array[1958] # for study in load_scm_studies():
self.assertTrue(time_serie.ndim == 2, msg='for {} ndim={}'.format(study.__repr__(), time_serie.ndim)) # time_serie = study.year_to_daily_time_serie_array[1958]
self.assertTrue(len(time_serie) in [365, 366], # self.assertTrue(time_serie.ndim == 2, msg='for {} ndim={}'.format(study.__repr__(), time_serie.ndim))
msg="current time serie length for {} is {}".format(study.__repr__(), len(time_serie))) # self.assertTrue(len(time_serie) in [365, 366],
# msg="current time serie length for {} is {}".format(study.__repr__(), len(time_serie)))
#
class TestSCMStudy(unittest.TestCase): #
# class TestSCMStudy(unittest.TestCase):
def setUp(self) -> None: #
super().setUp() # def setUp(self) -> None:
self.study = None # super().setUp()
# self.study = None
def check(self, massif_name_to_value_to_check): #
df_annual_total = self.study.df_annual_total # def check(self, massif_name_to_value_to_check):
for massif_name, value in massif_name_to_value_to_check.items(): # df_annual_total = self.study.df_annual_total
found_value = df_annual_total.loc[:, massif_name].mean() # for massif_name, value in massif_name_to_value_to_check.items():
self.assertEqual(value, self.round(found_value)) # found_value = df_annual_total.loc[:, massif_name].mean()
# self.assertEqual(value, self.round(found_value))
def round(self, f): #
raise NotImplementedError # def round(self, f):
# raise NotImplementedError
#
class TestSCMSafranSnowfall(TestSCMStudy): #
# class TestSCMSafranSnowfall(TestSCMStudy):
def setUp(self) -> None: #
super().setUp() # def setUp(self) -> None:
self.study = SafranSnowfall() # super().setUp()
# self.study = SafranSnowfall()
def test_massif_safran(self): #
df_centroid = pd.read_csv(op.join(self.study.map_full_path, 'coordonnees_massifs_alpes.csv')) # def test_massif_safran(self):
# Assert that the massif names are the same between SAFRAN and the coordinate file # df_centroid = pd.read_csv(op.join(self.study.map_full_path, 'coordonnees_massifs_alpes.csv'))
assert not set(self.study.study_massif_names).symmetric_difference(set(df_centroid['NOM'])) # # Assert that the massif names are the same between SAFRAN and the coordinate file
# assert not set(self.study.study_massif_names).symmetric_difference(set(df_centroid['NOM']))
#
class TestSCMPrecipitation(TestSCMStudy): #
# class TestSCMPrecipitation(TestSCMStudy):
def setUp(self) -> None: #
super().setUp() # def setUp(self) -> None:
self.study = SafranTotalPrecip(altitude=1800, year_min=1958, year_max=2002) # super().setUp()
# self.study = SafranTotalPrecip(altitude=1800, year_min=1958, year_max=2002)
def test_durand(self): #
# Test based on Durand paper # def test_durand(self):
# (some small differences probably due to the fact that SAFRAN model has evolved since then) # # Test based on Durand paper
# Test for the mean total precipitation (rainfall + snowfall) between 1958 and 2002 # # (some small differences probably due to the fact that SAFRAN model has evolved since then)
self.check({ # # Test for the mean total precipitation (rainfall + snowfall) between 1958 and 2002
"Mercantour": 1281, # self.check({
'Chablais': 1922, # "Mercantour": 1281,
}) # 'Chablais': 1922,
# })
def round(self, f): #
return int(f) # def round(self, f):
# return int(f)
#
class TestSafranTemperature(TestSCMStudy): #
# class TestSafranTemperature(TestSCMStudy):
def setUp(self): #
super().setUp() # def setUp(self):
self.study = SafranTemperature(altitude=1800, year_min=1958, year_max=2002) # super().setUp()
# self.study = SafranTemperature(altitude=1800, year_min=1958, year_max=2002)
def test_durand(self): #
# Test based on Durand paper # def test_durand(self):
# Test for the mean temperature between 1958 and 2002 # # Test based on Durand paper
self.check({ # # Test for the mean temperature between 1958 and 2002
"Mercantour": 5.3, # self.check({
'Chablais': 3.5, # "Mercantour": 5.3,
}) # 'Chablais': 3.5,
# })
def round(self, f): #
return round(float(f), 1) # def round(self, f):
# return round(float(f), 1)
#
if __name__ == '__main__': #
unittest.main() # if __name__ == '__main__':
# unittest.main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment