1111import numbers
1212import sys
1313from typing import (
14- TYPE_CHECKING ,
1514 Any ,
1615 cast ,
1716 overload ,
5352 pandas_dtype ,
5453)
5554
56- if TYPE_CHECKING :
57- from pandas ._typing import np_1darray
55+ from tests import (
56+ np_1darray ,
57+ np_1darray_bool ,
58+ np_ndarray ,
59+ )
5860
5961
6062@register_extension_dtype
@@ -94,7 +96,7 @@ class DecimalArray(OpsMixin, ExtensionScalarOpsMixin, ExtensionArray):
9496
9597 def __init__ (
9698 self ,
97- values : MutableSequence [decimal ._DecimalNew ] | np . ndarray | ExtensionArray ,
99+ values : MutableSequence [decimal ._DecimalNew ] | np_ndarray | ExtensionArray ,
98100 dtype : DecimalDtype | None = None ,
99101 copy : bool = False ,
100102 context : decimal .Context | None = None ,
@@ -126,7 +128,7 @@ def dtype(self) -> DecimalDtype:
126128 @classmethod
127129 def _from_sequence (
128130 cls ,
129- scalars : list [decimal ._DecimalNew ] | np . ndarray | ExtensionArray ,
131+ scalars : list [decimal ._DecimalNew ] | np_ndarray | ExtensionArray ,
130132 dtype : DecimalDtype | None = None ,
131133 copy : bool = False ,
132134 ) -> Self :
@@ -144,7 +146,7 @@ def _from_sequence_of_strings(
144146 @classmethod
145147 def _from_factorized (
146148 cls ,
147- values : list [decimal ._DecimalNew ] | np . ndarray | ExtensionArray ,
149+ values : list [decimal ._DecimalNew ] | np_ndarray | ExtensionArray ,
148150 original : Any ,
149151 ) -> Self :
150152 return cls (values )
@@ -157,7 +159,7 @@ def to_numpy(
157159 copy : bool = False ,
158160 na_value : object = no_default ,
159161 decimals : int | None = None ,
160- ) -> np . ndarray :
162+ ) -> np_ndarray :
161163 result = np .asarray (self , dtype = dtype )
162164 if decimals is not None :
163165 result = np .asarray ([round (x , decimals ) for x in result ])
@@ -192,7 +194,7 @@ def reconstruct(
192194 decimal .Decimal
193195 | numbers .Number
194196 | list [decimal ._DecimalNew ]
195- | np . ndarray
197+ | np_ndarray
196198 ),
197199 ) -> decimal .Decimal | numbers .Number | DecimalArray :
198200 if isinstance (x , (decimal .Decimal , numbers .Number )):
@@ -281,7 +283,7 @@ def nbytes(self) -> int:
281283 return n * sys .getsizeof (self [0 ])
282284 return 0
283285
284- def isna (self ) -> np_1darray [ np . bool_ ] :
286+ def isna (self ) -> np_1darray_bool :
285287 if sys .version_info < (3 , 11 ):
286288 return np .array ([x .is_nan () for x in self ._data ], bool ) # type: ignore[return-value] # pyright: ignore[reportReturnType]
287289 return np .array ([x .is_nan () for x in self ._data ], bool )
@@ -320,7 +322,7 @@ def _reduce(self, name: str, *, skipna: bool = True, **kwargs: Any) -> Any:
320322
321323 def _cmp_method (
322324 self , other : Any , op : Callable [[Self , ExtensionArray | list [Any ]], bool ]
323- ) -> np_1darray [ np . bool_ ] :
325+ ) -> np_1darray_bool :
324326 # For use with OpsMixin
325327 def convert_values (param : Any ) -> ExtensionArray | list [Any ]:
326328 if isinstance (param , ExtensionArray ) or is_list_like (param ):
@@ -337,9 +339,7 @@ def convert_values(param: Any) -> ExtensionArray | list[Any]:
337339 # a TypeError should be raised
338340 res = [op (a , b ) for (a , b ) in zip (lvalues , rvalues )]
339341
340- return cast (
341- np .ndarray [tuple [int ], np .dtype [np .bool_ ]], np .asarray (res , dtype = bool )
342- )
342+ return cast (np_1darray_bool , np .asarray (res , dtype = bool ))
343343
344344 def value_counts (self , dropna : bool = True ) -> Series :
345345 from pandas .core .algorithms import value_counts
0 commit comments