Skip to content

Commit 73e5e64

Browse files
authored
Better lint (#42)
* lint * doc
1 parent 9753f32 commit 73e5e64

16 files changed

+86
-85
lines changed

README.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ pandas-streaming: streaming API over pandas
55
:target: https://ci.appveyor.com/project/sdpython/pandas-streaming
66
:alt: Build Status Windows
77

8-
.. image:: https://dl.circleci.com/status-badge/img/gh/sdpython/pandas-streaming/tree/main.svg?style=svg
9-
:target: https://dl.circleci.com/status-badge/redirect/gh/sdpython/pandas-streaming/tree/main
10-
118
.. image:: https://dev.azure.com/xavierdupre3/pandas_streaming/_apis/build/status/sdpython.pandas_streaming
129
:target: https://dev.azure.com/xavierdupre3/pandas_streaming/
1310

_doc/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import sys
32
import os
43
from sphinx_runpython.github_link import make_linkcode_resolve

_doc/examples/first_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
First steps with pandas_streaming
33
=================================
4-
4+
55
A few difference between :epkg:`pandas` and *pandas_streaming*.
66
77
pandas to pandas_streaming

_doc/index.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ pandas-streaming: streaming API over pandas
99
:target: https://ci.appveyor.com/project/sdpython/pandas-streaming
1010
:alt: Build Status Windows
1111

12-
.. image:: https://dl.circleci.com/status-badge/img/gh/sdpython/pandas-streaming/tree/main.svg?style=svg
13-
:target: https://dl.circleci.com/status-badge/redirect/gh/sdpython/pandas-streaming/tree/main
14-
1512
.. image:: https://dev.azure.com/xavierdupre3/pandas_streaming/_apis/build/status/sdpython.pandas_streaming
1613
:target: https://dev.azure.com/xavierdupre3/pandas_streaming/
1714

_unittests/ut_df/test_connex_split.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def test_split_connex2(self):
176176
for k, v in sorted(stats[0].items()):
177177
rows.append(f"{k}={v}")
178178
raise AssertionError(
179-
"Non empty intersection {0} & {1}\n{2}\n{3}\n{4}".format(
179+
"Non empty intersection {0} & {1}\n{2}\n{3}\n{4}".format( # noqa: UP030
180180
s1, s2, train, test, "\n".join(rows)
181181
)
182182
)
@@ -212,7 +212,7 @@ def test_split_connex_missing(self):
212212
for k, v in sorted(stats[0].items()):
213213
rows.append(f"{k}={v}")
214214
raise AssertionError(
215-
"Non empty intersection {0} & {1}\n{2}\n{3}\n{4}".format(
215+
"Non empty intersection {0} & {1}\n{2}\n{3}\n{4}".format( # noqa: UP030
216216
s1, s2, train, test, "\n".join(rows)
217217
)
218218
)

_unittests/ut_df/test_connex_split_big.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
import os
32
import unittest
43
from collections import Counter

_unittests/ut_df/test_connex_split_cat.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import unittest
42
from collections import Counter
53
import pandas

_unittests/ut_df/test_streaming_dataframe.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_train_test_split_streaming_tiny(self):
223223

224224
def test_train_test_split_streaming_strat(self):
225225
sdf = dummy_streaming_dataframe(
226-
100, asfloat=True, tify=["t1" if i % 3 else "t0" for i in range(0, 100)]
226+
100, asfloat=True, tify=["t1" if i % 3 else "t0" for i in range(100)]
227227
)
228228
trsdf, tesdf = sdf.train_test_split(
229229
streaming=True, unique_rows=True, stratify="tify"
@@ -324,9 +324,9 @@ def test_concatv(self):
324324
self.assertEqualDataFrame(m1.to_dataframe(), df)
325325
m1 = sdf20.concat(df30, axis=0)
326326
self.assertEqualDataFrame(m1.to_dataframe(), df)
327-
m1 = sdf20.concat(map(lambda x: x, [df30]), axis=0)
327+
m1 = sdf20.concat(map(lambda x: x, [df30]), axis=0) # noqa: C417
328328
self.assertEqualDataFrame(m1.to_dataframe(), df)
329-
m1 = sdf20.concat(map(lambda x: x, [df30]), axis=0)
329+
m1 = sdf20.concat(map(lambda x: x, [df30]), axis=0) # noqa: C417
330330
self.assertEqualDataFrame(m1.to_dataframe(), df)
331331

332332
df20["cint"] = df20["cint"].astype(float)
@@ -490,7 +490,7 @@ def test_read_csv_names(self):
490490
def test_add_column(self):
491491
df = pandas.DataFrame(data=dict(X=[4.5, 6, 7], Y=["a", "b", "c"]))
492492
sdf = StreamingDataFrame.read_df(df)
493-
sdf2 = sdf.add_column("d", lambda row: int(1))
493+
sdf2 = sdf.add_column("d", lambda _row: 1)
494494
df2 = sdf2.to_dataframe()
495495
df["d"] = 1
496496
self.assertEqualDataFrame(df, df2)

pandas_streaming/data/dummy.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@ def dummy_streaming_dataframe(n, chunksize=10, asfloat=False, **cols):
1616
if asfloat:
1717
df = DataFrame(
1818
dict(
19-
cfloat=[_ + 0.1 for _ in range(0, n)],
20-
cstr=[f"s{i}" for i in range(0, n)],
19+
cfloat=[_ + 0.1 for _ in range(n)],
20+
cstr=[f"s{i}" for i in range(n)],
2121
)
2222
)
2323
else:
24-
df = DataFrame(
25-
dict(cint=list(range(0, n)), cstr=[f"s{i}" for i in range(0, n)])
26-
)
24+
df = DataFrame(dict(cint=list(range(n)), cstr=[f"s{i}" for i in range(n)]))
2725
for k, v in cols.items():
2826
df[k] = v
2927
return StreamingDataFrame.read_df(df, chunksize=chunksize)

pandas_streaming/df/connex_split.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class ImbalancedSplitException(Exception):
1212
Raised when an imbalanced split is detected.
1313
"""
1414

15-
pass
16-
1715

1816
def train_test_split_weights(
1917
df,
@@ -72,7 +70,7 @@ def train_test_split_weights(
7270
weights = list(df[weights])
7371
if len(weights) != df.shape[0]:
7472
raise ValueError(
75-
"Dimension mismatch between weights and dataframe "
73+
"Dimension mismatch between weights and dataframe " # noqa: UP030
7674
"{0} != {1}".format(df.shape[0], len(weights))
7775
)
7876

@@ -97,7 +95,7 @@ def train_test_split_weights(
9795
test_ids = []
9896
test_weights = 0
9997
train_weights = 0
100-
for i in range(0, df.shape[0]):
98+
for i in range(df.shape[0]):
10199
w = weights[i]
102100
if balance == 0:
103101
h = randint(0, 1)
@@ -116,7 +114,7 @@ def train_test_split_weights(
116114
r = abs(train_weights - test_weights) / (1.0 * (train_weights + test_weights))
117115
if r >= fail_imbalanced:
118116
raise ImbalancedSplitException( # pragma: no cover
119-
"Split is imbalanced: train_weights={0} test_weights={1} r={2}."
117+
"Split is imbalanced: train_weights={0} test_weights={1} r={2}." # noqa: UP030
120118
"".format(train_weights, test_weights, r)
121119
)
122120

0 commit comments

Comments
 (0)