From 64cc2f4eba70ae1e8a6964738eeb850e701f8964 Mon Sep 17 00:00:00 2001 From: nickleus27 Date: Mon, 8 Nov 2021 10:30:56 -0800 Subject: [PATCH 1/6] changed shape argument for ndarray fro int to tuple --- pandas/core/strings/object_array.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/strings/object_array.py b/pandas/core/strings/object_array.py index ba2f56c79bdfe..0a0086c1d858a 100644 --- a/pandas/core/strings/object_array.py +++ b/pandas/core/strings/object_array.py @@ -62,9 +62,7 @@ def _str_map( na_value = self._str_na_value if not len(self): - # error: Argument 1 to "ndarray" has incompatible type "int"; - # expected "Sequence[int]" - return np.ndarray(0, dtype=dtype) # type: ignore[arg-type] + return np.ndarray((0,), dtype=dtype) arr = np.asarray(self, dtype=object) mask = isna(arr) From 0fd3c66cfbcb14b776cdd1c2bcb977ac0293056d Mon Sep 17 00:00:00 2001 From: nickleus27 Date: Mon, 8 Nov 2021 14:48:45 -0800 Subject: [PATCH 2/6] changed variable hashed to combined_hashed in dtype.py --- pandas/core/dtypes/dtypes.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 21675ca0cdc7c..98121bf06b542 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -468,12 +468,10 @@ def _hash_categories(self) -> int: # error: Incompatible types in assignment (expression has type # "List[ndarray]", variable has type "ndarray") cat_array = [cat_array] # type: ignore[assignment] - # error: Incompatible types in assignment (expression has type "ndarray", - # variable has type "int") - hashed = combine_hash_arrays( # type: ignore[assignment] + combined_hashed = combine_hash_arrays( iter(cat_array), num_items=len(cat_array) ) - return np.bitwise_xor.reduce(hashed) + return np.bitwise_xor.reduce(combined_hashed) @classmethod def construct_array_type(cls) -> type_t[Categorical]: From c3e784f9470bfa6d4ea7763b3c099e7c75ef6296 Mon Sep 17 00:00:00 2001 From: nickleus27 Date: Mon, 8 Nov 2021 19:28:16 -0800 Subject: [PATCH 3/6] pre-commit changes --- pandas/core/dtypes/dtypes.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 98121bf06b542..e20670893f71c 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -468,9 +468,7 @@ def _hash_categories(self) -> int: # error: Incompatible types in assignment (expression has type # "List[ndarray]", variable has type "ndarray") cat_array = [cat_array] # type: ignore[assignment] - combined_hashed = combine_hash_arrays( - iter(cat_array), num_items=len(cat_array) - ) + combined_hashed = combine_hash_arrays(iter(cat_array), num_items=len(cat_array)) return np.bitwise_xor.reduce(combined_hashed) @classmethod From 540481735e5df4b02eef42962aae25a4f6381b42 Mon Sep 17 00:00:00 2001 From: nickleus27 Date: Tue, 9 Nov 2021 13:55:57 -0800 Subject: [PATCH 4/6] changed cat_array assignment to cat_array_list --- pandas/core/dtypes/dtypes.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index e20670893f71c..7d84d903c84b0 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -465,9 +465,11 @@ def _hash_categories(self) -> int: [cat_array, np.arange(len(cat_array), dtype=cat_array.dtype)] ) else: - # error: Incompatible types in assignment (expression has type - # "List[ndarray]", variable has type "ndarray") - cat_array = [cat_array] # type: ignore[assignment] + cat_array_list = [cat_array] + combined_hashed = combine_hash_arrays( + iter(cat_array_list), num_items=len(cat_array_list) + ) + return np.bitwise_xor.reduce(combined_hashed) combined_hashed = combine_hash_arrays(iter(cat_array), num_items=len(cat_array)) return np.bitwise_xor.reduce(combined_hashed) From bacef8a634aa7a3bc9f8254b2e159dd7c38552c1 Mon Sep 17 00:00:00 2001 From: nickleus27 Date: Wed, 10 Nov 2021 11:27:46 -0800 Subject: [PATCH 5/6] deleted Dtype import --- pandas/core/dtypes/dtypes.py | 8 +++----- pandas/core/strings/object_array.py | 5 +---- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index 7d84d903c84b0..e20670893f71c 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -465,11 +465,9 @@ def _hash_categories(self) -> int: [cat_array, np.arange(len(cat_array), dtype=cat_array.dtype)] ) else: - cat_array_list = [cat_array] - combined_hashed = combine_hash_arrays( - iter(cat_array_list), num_items=len(cat_array_list) - ) - return np.bitwise_xor.reduce(combined_hashed) + # error: Incompatible types in assignment (expression has type + # "List[ndarray]", variable has type "ndarray") + cat_array = [cat_array] # type: ignore[assignment] combined_hashed = combine_hash_arrays(iter(cat_array), num_items=len(cat_array)) return np.bitwise_xor.reduce(combined_hashed) diff --git a/pandas/core/strings/object_array.py b/pandas/core/strings/object_array.py index f45bf746fcdc2..352b789299b4d 100644 --- a/pandas/core/strings/object_array.py +++ b/pandas/core/strings/object_array.py @@ -12,10 +12,7 @@ import pandas._libs.lib as lib import pandas._libs.missing as libmissing import pandas._libs.ops as libops -from pandas._typing import ( - Dtype, - Scalar, -) +from pandas._typing import Scalar from pandas.core.dtypes.common import is_scalar from pandas.core.dtypes.missing import isna From 862bc8df4edbcc289d2832927a7431d7b5ce7f8c Mon Sep 17 00:00:00 2001 From: nickleus27 Date: Wed, 10 Nov 2021 22:50:04 -0800 Subject: [PATCH 6/6] changed dtype: NpDtype --- pandas/core/strings/object_array.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pandas/core/strings/object_array.py b/pandas/core/strings/object_array.py index 352b789299b4d..2ce5c0cbea272 100644 --- a/pandas/core/strings/object_array.py +++ b/pandas/core/strings/object_array.py @@ -7,12 +7,14 @@ import unicodedata import numpy as np -import numpy.typing as npt import pandas._libs.lib as lib import pandas._libs.missing as libmissing import pandas._libs.ops as libops -from pandas._typing import Scalar +from pandas._typing import ( + NpDtype, + Scalar, +) from pandas.core.dtypes.common import is_scalar from pandas.core.dtypes.missing import isna @@ -35,7 +37,7 @@ def __len__(self): raise NotImplementedError def _str_map( - self, f, na_value=None, dtype: npt.DTypeLike | None = None, convert: bool = True + self, f, na_value=None, dtype: NpDtype | None = None, convert: bool = True ): """ Map a callable over valid elements of the array.