Skip to content

Commit c15eee7

Browse files
wesmxhochy
authored andcommitted
ARROW-2395: [Python] Fix flake8 warnings outside of pyarrow/ directory. Check in CI
Author: Wes McKinney <wesm+git@apache.org> Closes #2137 from wesm/ARROW-2395 and squashes the following commits: d9e6e9f <Wes McKinney> Fix Cython flake8 warnings in examples 059a6d6 <Wes McKinney> Make functions in benchmarks/common.py py2-compatible 1379186 <Wes McKinney> Fix flake8 warnings outside of pyarrow/ directory. Check in CI
1 parent d4755e4 commit c15eee7

13 files changed

Lines changed: 46 additions & 46 deletions

File tree

ci/travis_lint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ if [ "$ARROW_CI_PYTHON_AFFECTED" != "0" ]; then
4343

4444
PYTHON_DIR=$TRAVIS_BUILD_DIR/python
4545

46-
flake8 --count $PYTHON_DIR/pyarrow
46+
flake8 --count $PYTHON_DIR
4747

4848
# Check Cython files with some checks turned off
4949
flake8 --count --config=$PYTHON_DIR/.flake8.cython \
50-
$PYTHON_DIR/pyarrow
50+
$PYTHON_DIR
5151
fi

python/benchmarks/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-

python/benchmarks/array_ops.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import numpy as np
1918
import pyarrow as pa
2019

2120

python/benchmarks/common.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import decimal
2020
from functools import partial
2121
import itertools
22-
import os
2322
import sys
2423
import unicodedata
2524

@@ -39,7 +38,7 @@ def _multiplicate_sequence(base, target_size):
3938
return [base] * q + [base[:r]]
4039

4140

42-
def get_random_bytes(n, *, seed=42):
41+
def get_random_bytes(n, seed=42):
4342
"""
4443
Generate a random bytes object of size *n*.
4544
Note the result might be compressible.
@@ -58,7 +57,7 @@ def get_random_bytes(n, *, seed=42):
5857
return result
5958

6059

61-
def get_random_ascii(n, *, seed=42):
60+
def get_random_ascii(n, seed=42):
6261
"""
6362
Get a random ASCII-only unicode string of size *n*.
6463
"""
@@ -69,7 +68,7 @@ def get_random_ascii(n, *, seed=42):
6968
return result
7069

7170

72-
def _random_unicode_letters(n, *, seed=42):
71+
def _random_unicode_letters(n, seed=42):
7372
"""
7473
Generate a string of random unicode letters (slow).
7574
"""
@@ -93,7 +92,7 @@ def _get_more_candidates():
9392
_1024_random_unicode_letters = _random_unicode_letters(1024)
9493

9594

96-
def get_random_unicode(n, *, seed=42):
95+
def get_random_unicode(n, seed=42):
9796
"""
9897
Get a random non-ASCII unicode string of size *n*.
9998
"""
@@ -179,7 +178,8 @@ def generate_object_list(self, n, none_prob=DEFAULT_NONE_PROB):
179178
self.sprinkle_nones(data, none_prob)
180179
return data
181180

182-
def _generate_varying_sequences(self, random_factory, n, min_size, max_size, none_prob):
181+
def _generate_varying_sequences(self, random_factory, n, min_size,
182+
max_size, none_prob):
183183
"""
184184
Generate a list of *n* sequences of varying size between *min_size*
185185
and *max_size*, with *none_prob* probability of an entry being None.
@@ -207,7 +207,6 @@ def generate_fixed_binary_list(self, n, size, none_prob=DEFAULT_NONE_PROB):
207207
return self._generate_varying_sequences(get_random_bytes, n,
208208
size, size, none_prob)
209209

210-
211210
def generate_varying_binary_list(self, n, min_size, max_size,
212211
none_prob=DEFAULT_NONE_PROB):
213212
"""
@@ -217,7 +216,6 @@ def generate_varying_binary_list(self, n, min_size, max_size,
217216
return self._generate_varying_sequences(get_random_bytes, n,
218217
min_size, max_size, none_prob)
219218

220-
221219
def generate_ascii_string_list(self, n, min_size, max_size,
222220
none_prob=DEFAULT_NONE_PROB):
223221
"""
@@ -227,7 +225,6 @@ def generate_ascii_string_list(self, n, min_size, max_size,
227225
return self._generate_varying_sequences(get_random_ascii, n,
228226
min_size, max_size, none_prob)
229227

230-
231228
def generate_unicode_string_list(self, n, min_size, max_size,
232229
none_prob=DEFAULT_NONE_PROB):
233230
"""
@@ -237,7 +234,6 @@ def generate_unicode_string_list(self, n, min_size, max_size,
237234
return self._generate_varying_sequences(get_random_unicode, n,
238235
min_size, max_size, none_prob)
239236

240-
241237
def generate_int_list_list(self, n, min_size, max_size,
242238
none_prob=DEFAULT_NONE_PROB):
243239
"""
@@ -263,7 +259,9 @@ def generate_tuple_list(self, n, none_prob=DEFAULT_NONE_PROB):
263259
def generate_dict_list(self, n, none_prob=DEFAULT_NONE_PROB):
264260
"""
265261
Generate a list of dicts with random values.
266-
Each dict has the form `{'u': int value, 'v': float value, 'w': bool value}`
262+
Each dict has the form
263+
264+
`{'u': int value, 'v': float value, 'w': bool value}`
267265
"""
268266
ints = self.generate_int_list(n, none_prob=none_prob)
269267
floats = self.generate_float_list(n, none_prob=none_prob)

python/benchmarks/microbenchmarks.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717

18-
import pyarrow as pa
1918
import pyarrow.benchmark as pb
2019

2120
from . import common
@@ -44,4 +43,3 @@ def setup(self, type_name):
4443

4544
def time_PandasObjectIsNull(self, *args):
4645
pb.benchmark_PandasObjectIsNull(self.lst)
47-

python/benchmarks/plasma.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
import numpy as np
1919
import timeit
2020

21-
import pyarrow as pa
2221
import pyarrow.plasma as plasma
2322

24-
from . import common
25-
2623

2724
class SimplePlasmaThroughput(object):
2825
"""Benchmark plasma store throughput with a single client."""
@@ -32,7 +29,8 @@ class SimplePlasmaThroughput(object):
3229
timer = timeit.default_timer
3330

3431
def setup(self, size):
35-
self.plasma_store_ctx = plasma.start_plasma_store(plasma_store_memory=10**9)
32+
self.plasma_store_ctx = plasma.start_plasma_store(
33+
plasma_store_memory=10**9)
3634
plasma_store_name, p = self.plasma_store_ctx.__enter__()
3735
self.plasma_client = plasma.connect(plasma_store_name, "", 64)
3836

@@ -51,7 +49,8 @@ class SimplePlasmaLatency(object):
5149
timer = timeit.default_timer
5250

5351
def setup(self):
54-
self.plasma_store_ctx = plasma.start_plasma_store(plasma_store_memory=10**9)
52+
self.plasma_store_ctx = plasma.start_plasma_store(
53+
plasma_store_memory=10**9)
5554
plasma_store_name, p = self.plasma_store_ctx.__enter__()
5655
self.plasma_client = plasma.connect(plasma_store_name, "", 64)
5756

python/benchmarks/streaming.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,15 @@
2626
def generate_chunks(total_size, nchunks, ncols, dtype=np.dtype('int64')):
2727
rowsize = total_size // nchunks // ncols
2828
assert rowsize % dtype.itemsize == 0
29+
30+
def make_column(col, chunk):
31+
return np.frombuffer(common.get_random_bytes(
32+
rowsize, seed=col + 997 * chunk)).view(dtype)
33+
2934
return [pd.DataFrame({
30-
'c' + str(col): np.frombuffer(
31-
common.get_random_bytes(rowsize, seed=col + 997 * chunk)).view(dtype)
32-
for col in range(ncols)
33-
})
34-
for chunk in range(nchunks)]
35+
'c' + str(col): make_column(col, chunk)
36+
for col in range(ncols)})
37+
for chunk in range(nchunks)]
3538

3639

3740
class StreamReader(object):
@@ -64,4 +67,4 @@ def setup(self, chunk_size):
6467
def time_read_to_dataframe(self, *args):
6568
reader = pa.RecordBatchStreamReader(self.source)
6669
table = reader.read_all()
67-
df = table.to_pandas()
70+
df = table.to_pandas() # noqa

python/doc/source/conf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# add these directories to sys.path here. If the directory is relative to the
3131
# documentation root, use os.path.abspath to make it absolute, like shown here.
3232
#
33+
import glob
3334
import os
3435
import sys
3536

@@ -77,7 +78,6 @@
7778
# source_suffix = ['.rst', '.md']
7879
source_suffix = '.rst'
7980

80-
import glob
8181
autosummary_generate = glob.glob("*.rst")
8282

8383
# The encoding of source files.
@@ -187,8 +187,8 @@
187187
# html_logo = None
188188

189189
# The name of an image file (relative to this directory) to use as a favicon of
190-
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
191-
# pixels large.
190+
# the docs. This file should be a Windows icon file (.ico) being 16x16 or
191+
# 32x32 pixels large.
192192
#
193193
# html_favicon = None
194194

python/examples/plasma/sorting/multimerge.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ from libc.stdint cimport uintptr_t
2323
from libcpp.vector cimport vector
2424
from libcpp.pair cimport pair
2525

26-
cimport numpy as np
2726
import numpy as np
2827

28+
cimport numpy as np
2929

3030
cdef extern from "<queue>" namespace "std" nogil:
3131
cdef cppclass priority_queue[T]:
@@ -44,7 +44,7 @@ def multimerge2d(*arrays):
4444
This assumes C style ordering for both input and output arrays. For
4545
each input array we have array[i,0] <= array[i+1,0] and for the output
4646
array the same will hold.
47-
47+
4848
Ideally this code would be simpler and also support both C style
4949
and Fortran style ordering.
5050
"""

python/examples/plasma/sorting/sort_df.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from multiprocessing import Pool
1919
import numpy as np
20-
import os
2120
import pandas as pd
2221
import pyarrow as pa
2322
import pyarrow.plasma as plasma

0 commit comments

Comments
 (0)