Skip to content

STYLE: final flake8 fixes, add back check for travis-ci #12208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,10 @@ script:
- echo "script"
- ci/run_build_docs.sh
- ci/script.sh
- ci/lint.sh
# nothing here, or failed tests won't fail travis

after_script:
- ci/install_test.sh
- source activate pandas && ci/print_versions.py
- ci/print_skipped.py /tmp/nosetests.xml
- ci/lint.sh
- ci/lint_ok_for_now.sh
17 changes: 7 additions & 10 deletions ci/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ echo "inside $0"

source activate pandas

for path in 'core'
RET=0
for path in 'core' 'io' 'stats' 'compat' 'sparse' 'tools' 'tseries' 'tests' 'computation' 'util'
do
echo "linting -> pandas/$path"
flake8 pandas/$path --filename '*.py' --statistics -q
flake8 pandas/$path --filename '*.py'
if [ $? -ne "0" ]; then
RET=1
fi
done

RET="$?"

# we are disabling the return code for now
# to have Travis-CI pass. When the code
# passes linting, re-enable
#exit "$RET"

exit 0
exit $RET
20 changes: 0 additions & 20 deletions ci/lint_ok_for_now.sh

This file was deleted.

5 changes: 3 additions & 2 deletions pandas/compat/numpy_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
_np_version_under1p11 = LooseVersion(_np_version) < '1.11'

if LooseVersion(_np_version) < '1.7.0':
raise ImportError('this version of pandas is incompatible with numpy < 1.7.0\n'
raise ImportError('this version of pandas is incompatible with '
'numpy < 1.7.0\n'
'your numpy version is {0}.\n'
'Please upgrade numpy to >= 1.7.0 to use '
'this pandas version'.format(_np_version))
Expand Down Expand Up @@ -61,7 +62,7 @@ def np_array_datetime64_compat(arr, *args, **kwargs):
isinstance(arr, string_and_binary_types):
arr = [tz_replacer(s) for s in arr]
else:
arr = tz_replacer(s)
arr = tz_replacer(arr)

return np.array(arr, *args, **kwargs)

Expand Down
1 change: 0 additions & 1 deletion pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
from pandas.tseries.index import DatetimeIndex
from pandas.tseries.tdi import TimedeltaIndex

import pandas.core.algorithms as algos
import pandas.core.base as base
import pandas.core.common as com
import pandas.core.format as fmt
Expand Down
9 changes: 4 additions & 5 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -2310,10 +2310,9 @@ def _get_grouper(obj, key=None, axis=0, level=None, sort=True):
except Exception:
all_in_columns = False

if (not any_callable and not all_in_columns
and not any_arraylike and not any_groupers
and match_axis_length
and level is None):
if not any_callable and not all_in_columns and \
not any_arraylike and not any_groupers and \
match_axis_length and level is None:
keys = [com._asarray_tuplesafe(keys)]

if isinstance(level, (tuple, list)):
Expand Down Expand Up @@ -3695,7 +3694,7 @@ def count(self):
return self._wrap_agged_blocks(data.items, list(blk))


from pandas.tools.plotting import boxplot_frame_groupby
from pandas.tools.plotting import boxplot_frame_groupby # noqa
DataFrameGroupBy.boxplot = boxplot_frame_groupby


Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -3981,7 +3981,7 @@ def form_blocks(arrays, names, axes):
klass=DatetimeTZBlock,
fastpath=True,
placement=[i], )
for i, names, array in datetime_tz_items]
for i, _, array in datetime_tz_items]
blocks.extend(dttz_blocks)

if len(bool_items):
Expand All @@ -3999,7 +3999,7 @@ def form_blocks(arrays, names, axes):
if len(cat_items) > 0:
cat_blocks = [make_block(array, klass=CategoricalBlock, fastpath=True,
placement=[i])
for i, names, array in cat_items]
for i, _, array in cat_items]
blocks.extend(cat_blocks)

if len(extra_locs):
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ def _unstack_multiple(data, clocs):
for i in range(len(clocs)):
val = clocs[i]
result = result.unstack(val)
clocs = [val if i > val else val - 1 for val in clocs]
clocs = [v if i > v else v - 1 for v in clocs]

return result

Expand Down
4 changes: 2 additions & 2 deletions pandas/sparse/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,10 @@ def _convert_frames(frames, index, columns, fill_value=np.nan, kind='block'):
output[item] = df

if index is None:
all_indexes = [df.index for df in output.values()]
all_indexes = [x.index for x in output.values()]
index = _get_combined_index(all_indexes)
if columns is None:
all_columns = [df.columns for df in output.values()]
all_columns = [x.columns for x in output.values()]
columns = _get_combined_index(all_columns)

index = _ensure_index(index)
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def transform(row):
return row

def transform2(row):
if (notnull(row['C']) and row['C'].startswith('shin')
and row['A'] == 'foo'):
if (notnull(row['C']) and row['C'].startswith('shin') and
row['A'] == 'foo'):
row['D'] = 7
return row

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2178,8 +2178,8 @@ def test_where(self):
def _safe_add(df):
# only add to the numeric items
def is_ok(s):
return (issubclass(s.dtype.type, (np.integer, np.floating))
and s.dtype != 'uint8')
return (issubclass(s.dtype.type, (np.integer, np.floating)) and
s.dtype != 'uint8')

return DataFrame(dict([(c, s + 1) if is_ok(s) else (c, s)
for c, s in compat.iteritems(df)]))
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/frame/test_query_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -581,8 +581,7 @@ def test_chained_cmp_and_in(self):
df = DataFrame(randn(100, len(cols)), columns=cols)
res = df.query('a < b < c and a not in b not in c', engine=engine,
parser=parser)
ind = ((df.a < df.b) & (df.b < df.c) & ~df.b.isin(df.a) &
~df.c.isin(df.b))
ind = (df.a < df.b) & (df.b < df.c) & ~df.b.isin(df.a) & ~df.c.isin(df.b) # noqa
expec = df[ind]
assert_frame_equal(res, expec)

Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/frame/test_repr_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,13 @@ def test_info_memory_usage(self):
res = buf.getvalue().splitlines()
self.assertTrue(re.match(r"memory usage: [^+]+$", res[-1]))

self.assertTrue(df_with_object_index.memory_usage(index=True,
deep=True).sum()
> df_with_object_index.memory_usage(index=True).sum())
self.assertGreater(df_with_object_index.memory_usage(index=True,
deep=True).sum(),
df_with_object_index.memory_usage(index=True).sum())

df_object = pd.DataFrame({'a': ['a']})
self.assertTrue(df_object.memory_usage(deep=True).sum()
> df_object.memory_usage().sum())
self.assertGreater(df_object.memory_usage(deep=True).sum(),
df_object.memory_usage().sum())

# Test a DataFrame with duplicate columns
dtypes = ['int64', 'int64', 'int64', 'float64']
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/frame/test_reshape.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import numpy as np

from pandas.compat import u
from pandas import DataFrame, Index, Series, MultiIndex, date_range, Timedelta, Period
from pandas import (DataFrame, Index, Series, MultiIndex, date_range,
Timedelta, Period)
import pandas as pd

from pandas.util.testing import (assert_series_equal,
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def test_none_comparison(self):
self.assertTrue(result.iat[0])
self.assertTrue(result.iat[1])

result = None == o
result = None == o # noqa
self.assertFalse(result.iat[0])
self.assertFalse(result.iat[1])

Expand Down
8 changes: 4 additions & 4 deletions pandas/tests/test_groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -3858,8 +3858,8 @@ def test_groupby_categorical(self):
np.arange(4).repeat(8), levels, ordered=True)
exp = CategoricalIndex(expc)
self.assert_index_equal(desc_result.index.get_level_values(0), exp)
exp = Index(['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max']
* 4)
exp = Index(['count', 'mean', 'std', 'min', '25%', '50%',
'75%', 'max'] * 4)
self.assert_index_equal(desc_result.index.get_level_values(1), exp)

def test_groupby_datetime_categorical(self):
Expand Down Expand Up @@ -3899,8 +3899,8 @@ def test_groupby_datetime_categorical(self):
np.arange(4).repeat(8), levels, ordered=True)
exp = CategoricalIndex(expc)
self.assert_index_equal(desc_result.index.get_level_values(0), exp)
exp = Index(['count', 'mean', 'std', 'min', '25%', '50%', '75%', 'max']
* 4)
exp = Index(['count', 'mean', 'std', 'min', '25%', '50%',
'75%', 'max'] * 4)
self.assert_index_equal(desc_result.index.get_level_values(1), exp)

def test_groupby_categorical_index(self):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/test_multilevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ def test_append_index(self):
expected = Index._simple_new(
np.array([(1.1, datetime.datetime(2011, 1, 1, tzinfo=tz), 'A'),
(1.2, datetime.datetime(2011, 1, 2, tzinfo=tz), 'B'),
(1.3, datetime.datetime(2011, 1, 3, tzinfo=tz), 'C')]
+ expected_tuples), None)
(1.3, datetime.datetime(2011, 1, 3, tzinfo=tz), 'C')] +
expected_tuples), None)
self.assertTrue(result.equals(expected))

def test_dataframe_constructor(self):
Expand Down
23 changes: 11 additions & 12 deletions pandas/tests/test_style.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import os
from nose import SkipTest

import copy
import numpy as np
import pandas as pd
from pandas import DataFrame
from pandas.util.testing import TestCase
import pandas.util.testing as tm

# this is a mess. Getting failures on a python 2.7 build with
# whenever we try to import jinja, whether it's installed or not.
# so we're explicitly skipping that one *before* we try to import
Expand All @@ -14,14 +21,6 @@
except ImportError:
raise SkipTest("No Jinja2")

import copy

import numpy as np
import pandas as pd
from pandas import DataFrame
from pandas.util.testing import TestCase
import pandas.util.testing as tm


class TestStyler(TestCase):

Expand Down Expand Up @@ -196,8 +195,8 @@ def test_apply_subset(self):
expected = dict(((r, c), ['color: baz'])
for r, row in enumerate(self.df.index)
for c, col in enumerate(self.df.columns)
if row in self.df.loc[slice_].index
and col in self.df.loc[slice_].columns)
if row in self.df.loc[slice_].index and
col in self.df.loc[slice_].columns)
self.assertEqual(result, expected)

def test_applymap_subset(self):
Expand All @@ -213,8 +212,8 @@ def f(x):
expected = dict(((r, c), ['foo: bar'])
for r, row in enumerate(self.df.index)
for c, col in enumerate(self.df.columns)
if row in self.df.loc[slice_].index
and col in self.df.loc[slice_].columns)
if row in self.df.loc[slice_].index and
col in self.df.loc[slice_].columns)
self.assertEqual(result, expected)

def test_empty(self):
Expand Down
51 changes: 25 additions & 26 deletions pandas/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1002,32 +1002,31 @@ def simple_wma(s, w):
return (s.multiply(w).cumsum() / w.cumsum()).fillna(method='ffill')

for (s, adjust, ignore_na, w) in [
(s0, True, False, [np.nan, (1. - alpha), 1.]),
(s0, True, True, [np.nan, (1. - alpha), 1.]),
(s0, False, False, [np.nan, (1. - alpha), alpha]),
(s0, False, True, [np.nan, (1. - alpha), alpha]),
(s1, True, False, [(1. - alpha) ** 2, np.nan, 1.]),
(s1, True, True, [(1. - alpha), np.nan, 1.]),
(s1, False, False, [(1. - alpha) ** 2, np.nan, alpha]),
(s1, False, True, [(1. - alpha), np.nan, alpha]),
(s2, True, False, [np.nan, (1. - alpha)
** 3, np.nan, np.nan, 1., np.nan]),
(s2, True, True, [np.nan, (1. - alpha),
np.nan, np.nan, 1., np.nan]),
(s2, False, False, [np.nan, (1. - alpha)
** 3, np.nan, np.nan, alpha, np.nan]),
(s2, False, True, [np.nan, (1. - alpha),
np.nan, np.nan, alpha, np.nan]),
(s3, True, False, [(1. - alpha)
** 3, np.nan, (1. - alpha), 1.]),
(s3, True, True, [(1. - alpha) **
2, np.nan, (1. - alpha), 1.]),
(s3, False, False, [(1. - alpha) ** 3, np.nan,
(1. - alpha) * alpha,
alpha * ((1. - alpha) ** 2 + alpha)]),
(s3, False, True, [(1. - alpha) ** 2,
np.nan, (1. - alpha) * alpha, alpha]),
]:
(s0, True, False, [np.nan, (1. - alpha), 1.]),
(s0, True, True, [np.nan, (1. - alpha), 1.]),
(s0, False, False, [np.nan, (1. - alpha), alpha]),
(s0, False, True, [np.nan, (1. - alpha), alpha]),
(s1, True, False, [(1. - alpha) ** 2, np.nan, 1.]),
(s1, True, True, [(1. - alpha), np.nan, 1.]),
(s1, False, False, [(1. - alpha) ** 2, np.nan, alpha]),
(s1, False, True, [(1. - alpha), np.nan, alpha]),
(s2, True, False, [np.nan, (1. - alpha) **
3, np.nan, np.nan, 1., np.nan]),
(s2, True, True, [np.nan, (1. - alpha),
np.nan, np.nan, 1., np.nan]),
(s2, False, False, [np.nan, (1. - alpha) **
3, np.nan, np.nan, alpha, np.nan]),
(s2, False, True, [np.nan, (1. - alpha),
np.nan, np.nan, alpha, np.nan]),
(s3, True, False, [(1. - alpha) **
3, np.nan, (1. - alpha), 1.]),
(s3, True, True, [(1. - alpha) **
2, np.nan, (1. - alpha), 1.]),
(s3, False, False, [(1. - alpha) ** 3, np.nan,
(1. - alpha) * alpha,
alpha * ((1. - alpha) ** 2 + alpha)]),
(s3, False, True, [(1. - alpha) ** 2,
np.nan, (1. - alpha) * alpha, alpha])]:
expected = simple_wma(s, Series(w))
result = s.ewm(com=com, adjust=adjust, ignore_na=ignore_na).mean()

Expand Down
5 changes: 2 additions & 3 deletions pandas/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,7 @@ def _get_merge_keys(self):

def _validate_specification(self):
# Hm, any way to make this logic less complicated??
if (self.on is None and self.left_on is None
and self.right_on is None):
if self.on is None and self.left_on is None and self.right_on is None:

if self.left_index and self.right_index:
self.left_on, self.right_on = (), ()
Expand Down Expand Up @@ -1185,7 +1184,7 @@ def _make_concat_multiindex(indexes, keys, levels=None, names=None):
names = list(names)
else:
# make sure that all of the passed indices have the same nlevels
if not len(set([i.nlevels for i in indexes])) == 1:
if not len(set([idx.nlevels for idx in indexes])) == 1:
raise AssertionError("Cannot concat indices that do"
" not have the same number of levels")

Expand Down
4 changes: 2 additions & 2 deletions pandas/tools/pivot.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def _convert_by(by):
if by is None:
by = []
elif (np.isscalar(by) or isinstance(by, (np.ndarray, Index,
Series, Grouper))
or hasattr(by, '__call__')):
Series, Grouper)) or
hasattr(by, '__call__')):
by = [by]
else:
by = list(by)
Expand Down
Loading