remove trailing spaces
This commit is contained in:
@@ -7,4 +7,4 @@ from .weightedDataset import WeightedDataset
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
# cursor: 16 del
|
||||
|
@@ -15,7 +15,7 @@ from .random_generator import random_generator
|
||||
|
||||
class Dataset(list):
|
||||
""" A dataset (a list) with statistics and latex rendering methods
|
||||
|
||||
|
||||
>>> s = Dataset(range(100))
|
||||
>>> s.sum()
|
||||
4950
|
||||
@@ -52,11 +52,11 @@ class Dataset(list):
|
||||
exact_mean)
|
||||
|
||||
return cls(data, data_name = data_name)
|
||||
|
||||
|
||||
def __init__(self, data = [], data_name = "Valeurs"):
|
||||
"""
|
||||
"""
|
||||
Create a numeric data set
|
||||
|
||||
|
||||
:param data: values of the data set
|
||||
:param data_name: name of the data set
|
||||
"""
|
||||
@@ -83,10 +83,10 @@ class Dataset(list):
|
||||
@number_factory
|
||||
def sum(self):
|
||||
return sum(self)
|
||||
|
||||
|
||||
@number_factory
|
||||
def mean(self):
|
||||
return self.sum()/self.effectif_total()
|
||||
return self.sum()/self.effectif_total()
|
||||
|
||||
@number_factory
|
||||
def deviation(self):
|
||||
@@ -97,7 +97,7 @@ class Dataset(list):
|
||||
@number_factory
|
||||
def variance(self):
|
||||
return self.deviation()/self.effectif_total()
|
||||
|
||||
|
||||
@number_factory
|
||||
def sd(self):
|
||||
""" Compute the standard deviation """
|
||||
@@ -150,18 +150,18 @@ class Dataset(list):
|
||||
return self[ceil(position)]
|
||||
|
||||
def posi_quartile(self, quartile = 1):
|
||||
"""
|
||||
"""
|
||||
Calcul la position du quartile
|
||||
|
||||
:param quartile: le quartile concerné
|
||||
|
||||
|
||||
:return : la position du quartile (arondis à l'entier suppérieur, non arrondis)
|
||||
"""
|
||||
return quartile * self.effectif_total() / 4
|
||||
|
||||
|
||||
# --------------------------
|
||||
# Rendu latex
|
||||
|
||||
|
||||
def tabular_latex(self, nbr_lines = 1):
|
||||
""" Latex code to display dataset as a tabular """
|
||||
d_per_line = self.effectif_total() // nbr_lines
|
||||
@@ -188,5 +188,5 @@ class Dataset(list):
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
# cursor: 16 del
|
||||
|
||||
|
@@ -23,5 +23,5 @@ def number_factory(fun):
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
# cursor: 16 del
|
||||
|
||||
|
@@ -70,5 +70,5 @@ def random_generator(length,\
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
# cursor: 16 del
|
||||
|
||||
|
@@ -16,7 +16,7 @@ from .number_tools import number_factory
|
||||
|
||||
class WeightedDataset(dict):
|
||||
""" A weighted dataset with statistics and latex rendering methods
|
||||
|
||||
|
||||
>>> w = WeightedDataset([1, 2, 3, 4], "Enfants", [10, 11, 12, 13])
|
||||
>>> print(w)
|
||||
{1: 10, 2: 11, 3: 12, 4: 13}
|
||||
@@ -32,12 +32,12 @@ class WeightedDataset(dict):
|
||||
1.24
|
||||
>>> w.sd()
|
||||
1.11
|
||||
|
||||
|
||||
"""
|
||||
|
||||
|
||||
def __init__(self, datas = [], data_name = "Valeurs", weights = [], weight_name = "Effectifs"):
|
||||
"""
|
||||
Initiate the WeightedDataset
|
||||
"""
|
||||
Initiate the WeightedDataset
|
||||
"""
|
||||
if datas and not weights:
|
||||
weightedDatas = Counter(datas)
|
||||
@@ -51,7 +51,7 @@ class WeightedDataset(dict):
|
||||
|
||||
self.data_name = data_name
|
||||
self.weight_name = weight_name
|
||||
|
||||
|
||||
def add_data(self, data, weight = 1):
|
||||
try:
|
||||
self[data] += weight
|
||||
@@ -72,7 +72,7 @@ class WeightedDataset(dict):
|
||||
|
||||
@number_factory
|
||||
def mean(self):
|
||||
return self.sum()/self.effectif_total()
|
||||
return self.sum()/self.effectif_total()
|
||||
|
||||
@number_factory
|
||||
def deviation(self):
|
||||
@@ -83,7 +83,7 @@ class WeightedDataset(dict):
|
||||
@number_factory
|
||||
def variance(self):
|
||||
return self.deviation()/self.effectif_total()
|
||||
|
||||
|
||||
@number_factory
|
||||
def sd(self):
|
||||
""" Compute the standard deviation """
|
||||
@@ -141,19 +141,19 @@ class WeightedDataset(dict):
|
||||
return expanded_values[ceil(position)]
|
||||
|
||||
def posi_quartile(self, quartile = 1):
|
||||
"""
|
||||
"""
|
||||
Calcul la position du quartile
|
||||
|
||||
:param quartile: le quartile concerné
|
||||
|
||||
|
||||
:return : la position du quartile (arondis à l'entier suppérieur, non arrondis)
|
||||
"""
|
||||
return quartile * self.effectif_total() / 4
|
||||
|
||||
|
||||
|
||||
|
||||
# --------------------------
|
||||
# Rendu latex
|
||||
|
||||
|
||||
def tabular_latex(self):
|
||||
""" Latex code to display dataset as a tabular """
|
||||
latex = "\\begin{{tabular}}{{|c|*{{{nbr_col}}}{{c|}}}} \n".format(nbr_col = len(self.keys()))
|
||||
@@ -176,5 +176,5 @@ class WeightedDataset(dict):
|
||||
# -----------------------------
|
||||
# Reglages pour 'vim'
|
||||
# vim:set autoindent expandtab tabstop=4 shiftwidth=4:
|
||||
# cursor: 16 del
|
||||
# cursor: 16 del
|
||||
|
||||
|
Reference in New Issue
Block a user