28
28
DtypeObj ,
29
29
F ,
30
30
Scalar ,
31
+ Shape ,
31
32
)
32
33
from pandas .compat ._optional import import_optional_dependency
33
34
@@ -650,22 +651,16 @@ def nanmean(
650
651
values , skipna , fill_value = 0 , mask = mask
651
652
)
652
653
dtype_sum = dtype_max
653
- dtype_count = np .float64
654
+ dtype_count = np .dtype ( np . float64 )
654
655
655
656
# not using needs_i8_conversion because that includes period
656
657
if dtype .kind in ["m" , "M" ]:
657
- # error: Incompatible types in assignment (expression has type "Type[float64]",
658
- # variable has type "dtype[Any]")
659
- dtype_sum = np .float64 # type: ignore[assignment]
658
+ dtype_sum = np .dtype (np .float64 )
660
659
elif is_integer_dtype (dtype ):
661
- # error: Incompatible types in assignment (expression has type "Type[float64]",
662
- # variable has type "dtype[Any]")
663
- dtype_sum = np .float64 # type: ignore[assignment]
660
+ dtype_sum = np .dtype (np .float64 )
664
661
elif is_float_dtype (dtype ):
665
662
dtype_sum = dtype
666
- # error: Incompatible types in assignment (expression has type "dtype[Any]",
667
- # variable has type "Type[float64]")
668
- dtype_count = dtype # type: ignore[assignment]
663
+ dtype_count = dtype
669
664
670
665
count = _get_counts (values .shape , mask , axis , dtype = dtype_count )
671
666
the_sum = _ensure_numeric (values .sum (axis , dtype = dtype_sum ))
@@ -787,7 +782,7 @@ def get_empty_reduction_result(
787
782
788
783
789
784
def _get_counts_nanvar (
790
- value_counts : Tuple [ int ] ,
785
+ values_shape : Shape ,
791
786
mask : Optional [np .ndarray ],
792
787
axis : Optional [int ],
793
788
ddof : int ,
@@ -799,7 +794,7 @@ def _get_counts_nanvar(
799
794
800
795
Parameters
801
796
----------
802
- values_shape : Tuple[int]
797
+ values_shape : Tuple[int, ... ]
803
798
shape tuple from values ndarray, used if mask is None
804
799
mask : Optional[ndarray[bool]]
805
800
locations in values that should be considered missing
@@ -816,7 +811,7 @@ def _get_counts_nanvar(
816
811
d : scalar or array
817
812
"""
818
813
dtype = get_dtype (dtype )
819
- count = _get_counts (value_counts , mask , axis , dtype = dtype )
814
+ count = _get_counts (values_shape , mask , axis , dtype = dtype )
820
815
# error: Unsupported operand types for - ("int" and "generic")
821
816
# error: Unsupported operand types for - ("float" and "generic")
822
817
d = count - dtype .type (ddof ) # type: ignore[operator]
@@ -991,11 +986,7 @@ def nansem(
991
986
if not is_float_dtype (values .dtype ):
992
987
values = values .astype ("f8" )
993
988
994
- # error: Argument 1 to "_get_counts_nanvar" has incompatible type
995
- # "Tuple[int, ...]"; expected "Tuple[int]"
996
- count , _ = _get_counts_nanvar (
997
- values .shape , mask , axis , ddof , values .dtype # type: ignore[arg-type]
998
- )
989
+ count , _ = _get_counts_nanvar (values .shape , mask , axis , ddof , values .dtype )
999
990
var = nanvar (values , axis = axis , skipna = skipna , ddof = ddof )
1000
991
1001
992
return np .sqrt (var ) / np .sqrt (count )
0 commit comments