From ea900338ff0294d2065ad659400768fd52254b39 Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:07:50 +0100 Subject: [PATCH 1/8] fix unreachable exception --- pandas/core/indexes/interval.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/interval.py b/pandas/core/indexes/interval.py index b1523cd6c0d0c..e6b2bc0953680 100644 --- a/pandas/core/indexes/interval.py +++ b/pandas/core/indexes/interval.py @@ -1053,11 +1053,11 @@ def interval_range(start=None, end=None, freq=None, periods=None, if periods is None or end is None: raise ValueError("must specify 2 of start, end, periods") start = end - periods * freq - elif end is None: + if end is None: if periods is None or start is None: raise ValueError("must specify 2 of start, end, periods") end = start + periods * freq - elif periods is None: + if periods is None: if start is None or end is None: raise ValueError("must specify 2 of start, end, periods") pass From 4353719c57fe0c31d13256767582b55438aaac1e Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:27:14 +0100 Subject: [PATCH 2/8] remove unreachable return --- pandas/core/internals.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/pandas/core/internals.py b/pandas/core/internals.py index 15851a17274ca..caf7db8070202 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -5154,8 +5154,6 @@ def dtype(self): return _get_dtype(maybe_promote(self.block.dtype, self.block.fill_value)[0]) - return self._dtype - @cache_readonly def is_null(self): if self.block is None: From 841933290ffbe3d1da01dec0229db6640c490f90 Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:28:14 +0100 Subject: [PATCH 3/8] fix argument name in call --- pandas/core/dtypes/cast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/dtypes/cast.py b/pandas/core/dtypes/cast.py index fd61813a57c98..16b0a5c8a74ca 100644 --- a/pandas/core/dtypes/cast.py +++ b/pandas/core/dtypes/cast.py @@ -668,7 +668,7 @@ def maybe_convert_objects(values, convert_dates=True, convert_numeric=True, if convert_timedeltas == 'coerce': from pandas.core.tools.timedeltas import to_timedelta - new_values = to_timedelta(values, coerce=True) + new_values = to_timedelta(values, errors='coerce') # if we are all nans then leave me alone if not isnull(new_values).all(): From 8fce8d36726b6a755fbcf82deb37df7c6b990c34 Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:30:08 +0100 Subject: [PATCH 4/8] fix argument name in formatting call, useless assignment and wrong exception raised --- pandas/core/generic.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 98999ec267c82..3a546f6318e6e 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -4285,7 +4285,7 @@ def asof(self, where, subset=None): raise ValueError("subset is not valid for Series") elif self.ndim > 2: raise NotImplementedError("asof is not implemented " - "for {type}".format(type(self))) + "for {type}".format(type=type(self))) else: if subset is None: subset = self.columns @@ -4980,7 +4980,7 @@ def last(self, offset): offset = to_offset(offset) - start_date = start = self.index[-1] - offset + start_date = self.index[-1] - offset start = self.index.searchsorted(start_date, side='right') return self.iloc[start:] @@ -5303,7 +5303,7 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None, # slice me out of the other else: - raise NotImplemented("cannot align with a higher dimensional " + raise NotImplementedError("cannot align with a higher dimensional " "NDFrame") elif is_list_like(other): From 91bc03f34e3b404e1fbedd0fdba4393227ea4236 Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:30:58 +0100 Subject: [PATCH 5/8] remove useless formatting argument --- pandas/core/sparse/array.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/sparse/array.py b/pandas/core/sparse/array.py index 8ac9d3916573e..c75de01b98e4e 100644 --- a/pandas/core/sparse/array.py +++ b/pandas/core/sparse/array.py @@ -125,7 +125,7 @@ def _sparse_array_op(left, right, op, name, series=False): name = name[1:] if name in ('and', 'or') and dtype == 'bool': - opname = 'sparse_{name}_uint8'.format(name=name, dtype=dtype) + opname = 'sparse_{name}_uint8'.format(name=name) # to make template simple, cast here left_sp_values = left.sp_values.view(np.uint8) right_sp_values = right.sp_values.view(np.uint8) From a35dc36a4f5fa9588d5afee01c3af9d7ce2377e1 Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:31:58 +0100 Subject: [PATCH 6/8] fix argument name in call --- pandas/io/parsers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 055d6d045d2f2..c2d5a629b03a3 100755 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -2211,7 +2211,7 @@ def _exclude_implicit_index(self, alldata): def get_chunk(self, size=None): if size is None: size = self.chunksize - return self.read(nrows=size) + return self.read(rows=size) def _convert_data(self, data): # apply converters From 116077e721d14636d6fd2e32b44c8a12ec1e9e6e Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 18:40:32 +0100 Subject: [PATCH 7/8] fix 2 useless assignments to self --- pandas/core/internals.py | 1 - pandas/tseries/offsets.py | 1 - 2 files changed, 2 deletions(-) diff --git a/pandas/core/internals.py b/pandas/core/internals.py index caf7db8070202..58690ad632152 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -4645,7 +4645,6 @@ def _block2d_to_blocknd(values, placement, shape, labels, ref_items): pvalues = np.empty(panel_shape, dtype=dtype) pvalues.fill(fill_value) - values = values for i in range(len(placement)): pvalues[i].flat[mask] = values[:, i] diff --git a/pandas/tseries/offsets.py b/pandas/tseries/offsets.py index f9f4adc1b2c81..2a120a0696836 100644 --- a/pandas/tseries/offsets.py +++ b/pandas/tseries/offsets.py @@ -1596,7 +1596,6 @@ def apply(self, other): if otherDay != self.weekday: other = other + timedelta((self.weekday - otherDay) % 7) k = k - 1 - other = other for i in range(k): other = other + self._inc else: From eecbbb82ea26ee4c64763a84d719e66ae1732d22 Mon Sep 17 00:00:00 2001 From: jhelie Date: Tue, 6 Jun 2017 22:54:10 +0100 Subject: [PATCH 8/8] fix test: respect PEP8 format --- pandas/core/generic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 3a546f6318e6e..accb7d0db1d2c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5303,8 +5303,8 @@ def _where(self, cond, other=np.nan, inplace=False, axis=None, level=None, # slice me out of the other else: - raise NotImplementedError("cannot align with a higher dimensional " - "NDFrame") + raise NotImplementedError("cannot align with a higher " + "dimensional NDFrame") elif is_list_like(other):