HyukjinKwon commented on code in PR #36145:
URL: https://github.com/apache/spark/pull/36145#discussion_r848147531
##########
python/pyspark/tests/test_statcounter.py:
##########
@@ -76,6 +76,32 @@ def test_merge_stats(self):
self.assertEqual(stats.sum(), 20.0)
self.assertAlmostEqual(stats.variance(), 1.25)
self.assertAlmostEqual(stats.sampleVariance(), 1.4285714285714286)
+ execution_statements = [
+ StatCounter([1.0, 2.0]).mergeStats(StatCounter(range(1, 301))),
+ StatCounter(range(1, 301)).mergeStats(StatCounter([1.0, 2.0])),
+ ]
+ for stats in execution_statements:
+ self.assertEqual(stats.count(), 302)
+ self.assertEqual(stats.max(), 300.0)
+ self.assertEqual(stats.min(), 1.0)
+ self.assertAlmostEqual(stats.mean(), 149.51324503311)
+ self.assertAlmostEqual(stats.variance(), 7596.302804701549)
+ self.assertAlmostEqual(stats.sampleVariance(), 7621.539691095905)
+
+ def test_variance_when_size_zero(self):
+ # SPARK-38854: Test case to improve test coverage when
+ # StatCounter argument is empty list or None
+ arguments = [[], None]
+ import math
Review Comment:
last nit. you can import this on the top of this file.
--
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]