From bcd6ceb332a449080f40d44ad2861e339e197089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Fri, 11 Jan 2019 20:32:52 +0100 Subject: [PATCH] pep8 --- _unittests/ut_homeblog/test_tableformula3.py | 4 ---- src/ensae_teaching_cs/homeblog/table_formula.py | 12 ++++++------ 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/_unittests/ut_homeblog/test_tableformula3.py b/_unittests/ut_homeblog/test_tableformula3.py index 1bf2d2787..1dbe3b6fe 100644 --- a/_unittests/ut_homeblog/test_tableformula3.py +++ b/_unittests/ut_homeblog/test_tableformula3.py @@ -5,10 +5,7 @@ import sys import os import unittest -import random import numpy -import pandas -from pyquickhelper.loghelper import fLOG from pyquickhelper.pycode import ExtTestCase @@ -47,7 +44,6 @@ def test_TableFormula_init(self): vals = [0., 1.] vals = [vals, vals] tbl = TableFormula(vals) - z = tbl tbl.header = ["x", "y"] np = numpy.array(vals) tbl2 = TableFormula(np) diff --git a/src/ensae_teaching_cs/homeblog/table_formula.py b/src/ensae_teaching_cs/homeblog/table_formula.py index a941ebc83..e09bf7f80 100644 --- a/src/ensae_teaching_cs/homeblog/table_formula.py +++ b/src/ensae_teaching_cs/homeblog/table_formula.py @@ -838,8 +838,8 @@ def __html__(self, class_table=None, class_td=None, class_tr=None, class_th=None clth = ' class="%s"' % class_th if class_th is not None else "" rows = ["" % clta] - rows.append(("" % (cltr, clth)) - + ("" % clth).join(self.header) + "") + rows.append("{0}{1}{2}".format(("" % (cltr, clth)), + ("" % clth).join(self.header), "")) septd = "" % cltd strtd = "" % (cltr, cltd) for row in self.values: @@ -1367,8 +1367,8 @@ def avg(vec): elif logging is not None: end = min(len(keep), 10) mes = ",".join([str(_) for _ in keep[:end]]) - logging("removing column " + col - + " no unique value: " + str(len(dd)) + ": " + mes) + logging("removing column '{0}' no unique value: {1}: {2}".format( + col, len(dd), mes)) elif col.startswith("sum"): functions.append(lambda v, col=col: identical(col, v)) labels.append(col) @@ -1792,7 +1792,7 @@ def filter_quantile(self, function, alpha_min=0.025, alpha_max=0.025): i2 = min(i2, lv) if i2 == i1: raise RuntimeError("unable to extract quantile, the table is either " - + "empty or chosen quantile are not correct") + "empty or chosen quantile are not correct") values = [_[1] for _ in values[i1:i2]] return self._private_getclass()(self.header, values) @@ -1851,7 +1851,7 @@ def random(self, n, unique=False): if unique: if n > len(self): raise ValueError("number of desired random rows is higher " - + "than the number of rows in the table") + "than the number of rows in the table") index = {} while len(index) < n: h = random.randint(0, len(self) - 1)