Commit 91aea614 authored by Le Roux Erwan's avatar Le Roux Erwan
Browse files

[SCM] instead of round, display instead a significant number of digits

parent 2d96a067
No related merge requests found
Showing with 13 additions and 3 deletions
+13 -3
...@@ -33,7 +33,7 @@ def study_iterator(study_class, only_first_one=False, both_altitude=False, verbo ...@@ -33,7 +33,7 @@ def study_iterator(study_class, only_first_one=False, both_altitude=False, verbo
def extended_visualization(): def extended_visualization():
for study_class in SCM_EXTENDED_STUDIES[1:2]: for study_class in SCM_EXTENDED_STUDIES[-1:]:
for study in study_iterator(study_class, only_first_one=True): for study in study_iterator(study_class, only_first_one=True):
study_visualizer = StudyVisualizer(study) study_visualizer = StudyVisualizer(study)
# study_visualizer.visualize_all_kde_graphs() # study_visualizer.visualize_all_kde_graphs()
...@@ -57,6 +57,7 @@ def complete_analysis(only_first_one=False): ...@@ -57,6 +57,7 @@ def complete_analysis(only_first_one=False):
for extended_study in study_iterator(extended_study_class, only_first_one=only_first_one): for extended_study in study_iterator(extended_study_class, only_first_one=only_first_one):
study_visualizer = StudyVisualizer(extended_study, save_to_file=True) study_visualizer = StudyVisualizer(extended_study, save_to_file=True)
study_visualizer.visualize_all_mean_and_max_graphs() study_visualizer.visualize_all_mean_and_max_graphs()
study_visualizer.visualize_all_experimental_law()
print('Study normal') print('Study normal')
for study in study_iterator(study_class, only_first_one=only_first_one): for study in study_iterator(study_class, only_first_one=only_first_one):
study_visualizer = StudyVisualizer(study, save_to_file=True) study_visualizer = StudyVisualizer(study, save_to_file=True)
......
...@@ -23,7 +23,7 @@ from extreme_estimator.margin_fits.gpd.gpdmle_fit import GpdMleFit ...@@ -23,7 +23,7 @@ from extreme_estimator.margin_fits.gpd.gpdmle_fit import GpdMleFit
from extreme_estimator.margin_fits.plot.create_shifted_cmap import get_color_rbga_shifted from extreme_estimator.margin_fits.plot.create_shifted_cmap import get_color_rbga_shifted
from spatio_temporal_dataset.dataset.abstract_dataset import AbstractDataset from spatio_temporal_dataset.dataset.abstract_dataset import AbstractDataset
from test.test_utils import load_test_max_stable_models from test.test_utils import load_test_max_stable_models
from utils import get_display_name_from_object_type, VERSION_TIME from utils import get_display_name_from_object_type, VERSION_TIME, float_to_str_with_only_some_significant_digits
class StudyVisualizer(object): class StudyVisualizer(object):
...@@ -89,7 +89,9 @@ class StudyVisualizer(object): ...@@ -89,7 +89,9 @@ class StudyVisualizer(object):
ax.set_ylabel('Density', color=color_kde) ax.set_ylabel('Density', color=color_kde)
ax.set_xlabel(self.study.title) ax.set_xlabel(self.study.title)
extraticks = [round(x) for x in sorted(list(x_level_to_color.keys()))] extraticks = [float(float_to_str_with_only_some_significant_digits(x, nb_digits=2))
for x in sorted(list(x_level_to_color.keys()))]
extraticks = [extraticks[0], extraticks[-1]]
ax.set_xticks(extraticks) ax.set_xticks(extraticks)
ax.set_title(self.study.safran_massif_names[massif_id]) ax.set_title(self.study.safran_massif_names[massif_id])
......
...@@ -6,6 +6,7 @@ VERSION_TIME = str(VERSION).split('.')[0] ...@@ -6,6 +6,7 @@ VERSION_TIME = str(VERSION).split('.')[0]
for c in [' ', ':', '-']: for c in [' ', ':', '-']:
VERSION_TIME = VERSION_TIME.replace(c, '_') VERSION_TIME = VERSION_TIME.replace(c, '_')
def get_root_path() -> str: def get_root_path() -> str:
return op.dirname(op.abspath(__file__)) return op.dirname(op.abspath(__file__))
...@@ -27,6 +28,12 @@ def first(s): ...@@ -27,6 +28,12 @@ def first(s):
return next(iter(s)) return next(iter(s))
def float_to_str_with_only_some_significant_digits(f, nb_digits) -> str:
assert isinstance(nb_digits, int)
assert nb_digits > 0
return '%s' % float('%.{}g'.format(nb_digits) % f)
# todo: these cached property have a weird behavior with inheritence, # todo: these cached property have a weird behavior with inheritence,
# when we call the super cached_property in the child method # when we call the super cached_property in the child method
class cached_property(object): class cached_property(object):
......
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