Skip to content

Commit 14598c6

Browse files
MatanCohegfyoung
authored andcommitted
STYLE: Fix linting of benchmarks (#22886)
Fixed the following: * asv_bench/benchmarks/algorithms.py:12:5: E722 do not use bare except' * asv_bench/benchmarks/timeseries.py:1:1: F401 'warnings' imported but unused * asv_bench/benchmarks/stat_ops.py:21:9: E722 do not use bare except' * asv_bench/benchmarks/stat_ops.py:59:9: E722 do not use bare except' * asv_bench/benchmarks/pandas_vb_common.py:5:1: F401 'pandas.Panel' imported but unused * asv_bench/benchmarks/pandas_vb_common.py:12:5: E722 do not use bare except' * asv_bench/benchmarks/pandas_vb_common.py:37:9: E722 do not use bare except' * asv_bench/benchmarks/join_merge.py:32:9: E722 do not use bare except' * asv_bench/benchmarks/io/csv.py:2:1: F401 'timeit' imported but unused * asv_bench/benchmarks/io/csv.py:8:1: F401 'pandas.compat.PY2' imported but unused * asv_bench/benchmarks/io/csv.py:184:80: E501 line too long (87 > 79 characters)
1 parent f849134 commit 14598c6

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

asv_bench/benchmarks/algorithms.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
try:
1010
hashing = import_module(imp)
1111
break
12-
except:
12+
except (ImportError, TypeError, ValueError):
1313
pass
1414

1515
from .pandas_vb_common import setup # noqa

asv_bench/benchmarks/io/csv.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import random
2-
import timeit
32
import string
43

54
import numpy as np
65
import pandas.util.testing as tm
76
from pandas import DataFrame, Categorical, date_range, read_csv
8-
from pandas.compat import PY2
97
from pandas.compat import cStringIO as StringIO
108

119
from ..pandas_vb_common import setup, BaseIO # noqa
@@ -181,8 +179,8 @@ def time_read_csv(self, sep, decimal, float_precision):
181179
names=list('abc'), float_precision=float_precision)
182180

183181
def time_read_csv_python_engine(self, sep, decimal, float_precision):
184-
read_csv(self.data(self.StringIO_input), sep=sep, header=None, engine='python',
185-
float_precision=None, names=list('abc'))
182+
read_csv(self.data(self.StringIO_input), sep=sep, header=None,
183+
engine='python', float_precision=None, names=list('abc'))
186184

187185

188186
class ReadCSVCategorical(BaseIO):

asv_bench/benchmarks/join_merge.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def setup(self):
2929
try:
3030
with warnings.catch_warnings(record=True):
3131
self.mdf1.consolidate(inplace=True)
32-
except:
32+
except (AttributeError, TypeError):
3333
pass
3434
self.mdf2 = self.mdf1.copy()
3535
self.mdf2.index = self.df2.index

asv_bench/benchmarks/pandas_vb_common.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
from importlib import import_module
33

44
import numpy as np
5-
from pandas import Panel
65

76
# Compatibility import for lib
87
for imp in ['pandas._libs.lib', 'pandas.lib']:
98
try:
109
lib = import_module(imp)
1110
break
12-
except:
11+
except (ImportError, TypeError, ValueError):
1312
pass
1413

1514
numeric_dtypes = [np.int64, np.int32, np.uint32, np.uint64, np.float32,
@@ -34,7 +33,7 @@ def remove(self, f):
3433
"""Remove created files"""
3534
try:
3635
os.remove(f)
37-
except:
36+
except OSError:
3837
# On Windows, attempting to remove a file that is in use
3938
# causes an exception to be raised
4039
pass

asv_bench/benchmarks/stat_ops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def setup(self, op, dtype, axis, use_bottleneck):
1818
df = pd.DataFrame(np.random.randn(100000, 4)).astype(dtype)
1919
try:
2020
pd.options.compute.use_bottleneck = use_bottleneck
21-
except:
21+
except TypeError:
2222
from pandas.core import nanops
2323
nanops._USE_BOTTLENECK = use_bottleneck
2424
self.df_func = getattr(df, op)
@@ -56,7 +56,7 @@ def setup(self, op, dtype, use_bottleneck):
5656
s = pd.Series(np.random.randn(100000)).astype(dtype)
5757
try:
5858
pd.options.compute.use_bottleneck = use_bottleneck
59-
except:
59+
except TypeError:
6060
from pandas.core import nanops
6161
nanops._USE_BOTTLENECK = use_bottleneck
6262
self.s_func = getattr(s, op)

asv_bench/benchmarks/timeseries.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warnings
21
from datetime import timedelta
32

43
import numpy as np

0 commit comments

Comments
 (0)