dchvn commented on a change in pull request #34435:
URL: https://github.com/apache/spark/pull/34435#discussion_r743476830
##########
File path: python/pyspark/statcounter.py
##########
@@ -114,24 +120,24 @@ def variance(self):
# Return the sample variance, which corrects for bias in estimating the
variance by dividing
# by N-1 instead of N.
#
- def sampleVariance(self):
+ def sampleVariance(self) -> float:
if self.n <= 1:
return float('nan')
else:
return self.m2 / (self.n - 1)
# Return the standard deviation of the values.
- def stdev(self):
+ def stdev(self) -> float:
return sqrt(self.variance())
#
# Return the sample standard deviation of the values, which corrects for
bias in estimating the
# variance by dividing by N-1 instead of N.
#
- def sampleStdev(self):
+ def sampleStdev(self) -> float:
return sqrt(self.sampleVariance())
- def asDict(self, sample=False):
+ def asDict(self, sample: bool = False) -> Dict[str, Union[float, int]]:
Review comment:
@zero323 I think we should keep ```Dict[str, Union[float, int]]```
because of ```'count': self.count()``` is ```int``` in the return. WDYT?
##########
File path: python/pyspark/statcounter.py
##########
@@ -19,18 +19,19 @@
import copy
import math
+from typing import cast, Dict, Iterable, Optional, Union
try:
from numpy import maximum, minimum, sqrt
except ImportError:
- maximum = max
- minimum = min
- sqrt = math.sqrt
+ maximum = max # type: ignore
+ minimum = min # type: ignore
+ sqrt = math.sqrt # type: ignore
Review comment:
@HyukjinKwon, as the issue
[#1153](https://github.com/python/mypy/issues/1153) in mypy, I think we should
ignore this. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]