Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
fixing issues pep8 + renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed May 2, 2016
1 parent c343088 commit 67255b9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
11 changes: 6 additions & 5 deletions _unittests/ut_modules/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import pyquickhelper as skip_

try:
import pyPdf
from pyPdf import PdfFileReader
except ImportError:
path = os.path.normpath(
os.path.abspath(
Expand All @@ -50,12 +50,11 @@
"pyPdf")))
if path not in sys.path:
sys.path.append(path)
import pyPdf
from pyPdf import PdfFileReader


from pyquickhelper.loghelper import fLOG
from src.ensae_teaching_cs.helpers.pypdf2_helper import pdf_read_content
from pyPdf import PdfFileReader
from src.ensae_teaching_cs.helpers.pypdf_helper import pdf_read_content


class TestModulesPdfReader(unittest.TestCase):
Expand Down Expand Up @@ -100,7 +99,9 @@ def test_read_function(self):
text = pdf_read_content(pdffile)
assert " " in text
assert "\n" in text
if "algorithms:theirinability" not in text:
if "algorithms:theirinability" not in text.replace(" ", ""):
raise Exception(text)
if "their inability" not in text:
raise Exception(text)

if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def pdf_read_content(filename):
If a line ends by "-", it is assumed a word was split. It is replaced by "---".
This function only works with `sdpython/pyPdf <https://github.com/sdpython/pyPdf>`_.
The module was modified to work better with spaces.
Every line ending by ``'---'`` is a split word.
"""
texts = []
with open(filename, "rb") as f:
Expand Down
8 changes: 4 additions & 4 deletions src/ensae_teaching_cs/special/elections.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def proc(row):
return None
return res
rows = list(map(lambda r: proc(r), tour.values))
rows = [_ for _ in rows if _ != None]
rows = [_ for _ in rows if _ is not None]
return pandas.DataFrame(rows)

def vote_transfer(self):
Expand Down Expand Up @@ -226,7 +226,7 @@ def _zeros(lin, col):

Q = None
for m in pX:
if Q == None:
if Q is None:
Q = +m
else:
Q += m * 2
Expand All @@ -237,7 +237,7 @@ def _zeros(lin, col):
tr = bigX[i].transpose()
y2 = Y[:, i] * (-2)
t = tr * y2
if p == None:
if p is None:
p = t
else:
p += t
Expand Down Expand Up @@ -361,7 +361,7 @@ def bootstrap(self, iter=1000, method="vote_transfer", alpha=0.05, fLOG=None, **
@param params parameters to give to ``method``
@return four matrices, averaged results, sigma, lower bound, higher bound
"""
if fLOG == None:
if fLOG is None:
fLOG = lambda *x: ""
fLOG("sampling", iter)
samples = [self.resample() for i in range(iter)]
Expand Down

0 comments on commit 67255b9

Please sign in to comment.