Robustifie calculs stats sur types exotiques / 9.1.51
This commit is contained in:
parent
f62286cf0e
commit
49ef7edd26
@ -20,15 +20,18 @@ class StatsMoyenne:
|
|||||||
"""Calcul les statistiques.
|
"""Calcul les statistiques.
|
||||||
Les valeurs NAN ou non numériques sont toujours enlevées.
|
Les valeurs NAN ou non numériques sont toujours enlevées.
|
||||||
Si vals is None, renvoie des zéros (utilisé pour UE bonus)
|
Si vals is None, renvoie des zéros (utilisé pour UE bonus)
|
||||||
"""
|
"""sco_ver
|
||||||
if vals is None or len(vals) == 0:
|
try:
|
||||||
|
if vals is None or len(vals) == 0 or np.isnan(vals).all():
|
||||||
|
self.moy = self.min = self.max = self.size = self.nb_vals = 0
|
||||||
|
else:
|
||||||
|
self.moy = np.nanmean(vals)
|
||||||
|
self.min = np.nanmin(vals)
|
||||||
|
self.max = np.nanmax(vals)
|
||||||
|
self.size = len(vals)
|
||||||
|
self.nb_vals = self.size - np.count_nonzero(np.isnan(vals))
|
||||||
|
except TypeError: # que des NaN dans un array d'objets, ou ce genre de choses exotiques...
|
||||||
self.moy = self.min = self.max = self.size = self.nb_vals = 0
|
self.moy = self.min = self.max = self.size = self.nb_vals = 0
|
||||||
else:
|
|
||||||
self.moy = np.nanmean(vals)
|
|
||||||
self.min = np.nanmin(vals)
|
|
||||||
self.max = np.nanmax(vals)
|
|
||||||
self.size = len(vals)
|
|
||||||
self.nb_vals = self.size - np.count_nonzero(np.isnan(vals))
|
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
"Tous les attributs dans un dict"
|
"Tous les attributs dans un dict"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# -*- mode: python -*-
|
# -*- mode: python -*-
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
SCOVERSION = "9.1.50"
|
SCOVERSION = "9.1.51"
|
||||||
|
|
||||||
SCONAME = "ScoDoc"
|
SCONAME = "ScoDoc"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user