From 8eb8acd8997ede850d7d0ca831951c80f1bd0e76 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand Date: Sun, 13 Nov 2016 16:18:26 +0300 Subject: [PATCH] manage nan in round_half_point --- notes_tools/df_marks_manip.py | 9 ++++----- notes_tools/test/test_df_marks_manip.py | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/notes_tools/df_marks_manip.py b/notes_tools/df_marks_manip.py index cb68f5f..55cd4d3 100644 --- a/notes_tools/df_marks_manip.py +++ b/notes_tools/df_marks_manip.py @@ -8,11 +8,10 @@ from math import ceil # Values manipulations def round_half_point(val): - return 0.5 * ceil(2.0 * val) - #try: - # return 0.5 * ceil(2.0 * val) - #except ValueError: - # return val + try: + return 0.5 * ceil(2.0 * val) + except ValueError: + return val latex_caract = ["\\NoRep", "\\RepZ", "\\RepU", "\\RepD", "\\RepT"] def note_to_rep(x): diff --git a/notes_tools/test/test_df_marks_manip.py b/notes_tools/test/test_df_marks_manip.py index b2d7985..2b9058e 100644 --- a/notes_tools/test/test_df_marks_manip.py +++ b/notes_tools/test/test_df_marks_manip.py @@ -12,6 +12,7 @@ def test_round_half_point(): assert df_marks_manip.round_half_point(2.4) == 2.5 assert df_marks_manip.round_half_point(2.6) == 3 assert df_marks_manip.round_half_point(2.9) == 3 + assert df_marks_manip.round_half_point(pandas.np.nan) def test_note_to_rep(): d = {"Niveau": 1, "Note": 0}