From 5f906e525a64a923fc2a28afd44b408721056734 Mon Sep 17 00:00:00 2001 From: grtcoder Date: Sat, 12 Nov 2022 17:05:24 +0530 Subject: [PATCH 1/2] STYLE: fix pylint redefined-outer-name warnings (#49656) Fixed warnings for the following files :- - pandas/core/arrays/datetimelike.py - pandas/core/base.py - pandas/core/computation/pytables.py --- pandas/core/arrays/datetimelike.py | 4 ++-- pandas/core/base.py | 12 ++++-------- pandas/core/computation/pytables.py | 4 ++-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index b36eeab70726e..63c621907a70c 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -112,13 +112,13 @@ ) from pandas.core import ( + algorithms, nanops, ops, ) from pandas.core.algorithms import ( checked_add_with_arr, isin, - mode, unique1d, ) from pandas.core.arraylike import OpsMixin @@ -1690,7 +1690,7 @@ def _mode(self, dropna: bool = True): if dropna: mask = self.isna() - i8modes = mode(self.view("i8"), mask=mask) + i8modes = algorithms.algos.mode(self.view("i8"), mask=mask) npmodes = i8modes.view(self._ndarray.dtype) npmodes = cast(np.ndarray, npmodes) return self._from_backing_data(npmodes) diff --git a/pandas/core/base.py b/pandas/core/base.py index 46803e1f28975..8949c78e68e84 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -61,11 +61,7 @@ ops, ) from pandas.core.accessor import DirNamesMixin -from pandas.core.algorithms import ( - duplicated, - unique1d, - value_counts, -) +from pandas.core.algorithms import algos from pandas.core.arraylike import OpsMixin from pandas.core.arrays import ExtensionArray from pandas.core.construction import ( @@ -991,7 +987,7 @@ def value_counts( NaN 1 dtype: int64 """ - return value_counts( + return algos.value_counts( self, sort=sort, ascending=ascending, @@ -1006,7 +1002,7 @@ def unique(self): # i.e. ExtensionArray result = values.unique() else: - result = unique1d(values) + result = algos.unique1d(values) return result @final @@ -1294,7 +1290,7 @@ def drop_duplicates(self, *, keep: DropKeep = "first"): @final def _duplicated(self, keep: DropKeep = "first") -> npt.NDArray[np.bool_]: - return duplicated(self._values, keep=keep) + return algos.duplicated(self._values, keep=keep) def _arith_method(self, other, op): res_name = ops.get_op_result_name(self, other) diff --git a/pandas/core/computation/pytables.py b/pandas/core/computation/pytables.py index ea7b8b654efa1..93928d8bf6b83 100644 --- a/pandas/core/computation/pytables.py +++ b/pandas/core/computation/pytables.py @@ -650,7 +650,7 @@ def maybe_expression(s) -> bool: """loose checking if s is a pytables-acceptable expression""" if not isinstance(s, str): return False - ops = PyTablesExprVisitor.binary_ops + PyTablesExprVisitor.unary_ops + ("=",) + operations = PyTablesExprVisitor.binary_ops + PyTablesExprVisitor.unary_ops + ("=",) # make sure we have an op at least - return any(op in s for op in ops) + return any(op in s for op in operations) From ed4ee8ab8f11e0b37c3275c5bfcfcac764753554 Mon Sep 17 00:00:00 2001 From: grtcoder Date: Sun, 13 Nov 2022 14:28:15 +0530 Subject: [PATCH 2/2] STYLE: fix pylint redefined-outer-name warnings (#49656) Fixed warnings for the following files :- - pandas/core/arrays/datetimelike.py - pandas/core/base.py - pandas/core/computation/pytables.py Iteration :- 2 --- pandas/core/arrays/datetimelike.py | 2 +- pandas/core/base.py | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/core/arrays/datetimelike.py b/pandas/core/arrays/datetimelike.py index 63c621907a70c..1ba82fc2f063a 100644 --- a/pandas/core/arrays/datetimelike.py +++ b/pandas/core/arrays/datetimelike.py @@ -1690,7 +1690,7 @@ def _mode(self, dropna: bool = True): if dropna: mask = self.isna() - i8modes = algorithms.algos.mode(self.view("i8"), mask=mask) + i8modes = algorithms.mode(self.view("i8"), mask=mask) npmodes = i8modes.view(self._ndarray.dtype) npmodes = cast(np.ndarray, npmodes) return self._from_backing_data(npmodes) diff --git a/pandas/core/base.py b/pandas/core/base.py index 8949c78e68e84..3d06c1830cc53 100644 --- a/pandas/core/base.py +++ b/pandas/core/base.py @@ -61,7 +61,6 @@ ops, ) from pandas.core.accessor import DirNamesMixin -from pandas.core.algorithms import algos from pandas.core.arraylike import OpsMixin from pandas.core.arrays import ExtensionArray from pandas.core.construction import ( @@ -987,7 +986,7 @@ def value_counts( NaN 1 dtype: int64 """ - return algos.value_counts( + return algorithms.value_counts( self, sort=sort, ascending=ascending, @@ -1002,7 +1001,7 @@ def unique(self): # i.e. ExtensionArray result = values.unique() else: - result = algos.unique1d(values) + result = algorithms.unique1d(values) return result @final @@ -1290,7 +1289,7 @@ def drop_duplicates(self, *, keep: DropKeep = "first"): @final def _duplicated(self, keep: DropKeep = "first") -> npt.NDArray[np.bool_]: - return algos.duplicated(self._values, keep=keep) + return algorithms.duplicated(self._values, keep=keep) def _arith_method(self, other, op): res_name = ops.get_op_result_name(self, other)