diff options
author | Raymond Hettinger <rhettinger@users.noreply.github.com> | 2020-04-16 17:25:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-16 17:25:14 (GMT) |
commit | 70f027dd22d6522b777d10c250f951e5e416b93a (patch) | |
tree | b0208da206e983459af5eb714dc38ed026c51153 /Lib/test | |
parent | 518835f3354d6672e61c9f52348c1e4a2533ea00 (diff) | |
download | cpython-70f027dd22d6522b777d10c250f951e5e416b93a.zip cpython-70f027dd22d6522b777d10c250f951e5e416b93a.tar.gz cpython-70f027dd22d6522b777d10c250f951e5e416b93a.tar.bz2 |
bpo-40290: Add zscore() to statistics.NormalDist. (GH-19547)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_statistics.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_statistics.py b/Lib/test/test_statistics.py index a9a427b..0e46a71 100644 --- a/Lib/test/test_statistics.py +++ b/Lib/test/test_statistics.py @@ -2602,6 +2602,21 @@ class TestNormalDist: with self.assertRaises(self.module.StatisticsError): NormalDist(1, 0).overlap(X) # left operand sigma is zero + def test_zscore(self): + NormalDist = self.module.NormalDist + X = NormalDist(100, 15) + self.assertEqual(X.zscore(142), 2.8) + self.assertEqual(X.zscore(58), -2.8) + self.assertEqual(X.zscore(100), 0.0) + with self.assertRaises(TypeError): + X.zscore() # too few arguments + with self.assertRaises(TypeError): + X.zscore(1, 1) # too may arguments + with self.assertRaises(TypeError): + X.zscore(None) # non-numeric type + with self.assertRaises(self.module.StatisticsError): + NormalDist(1, 0).zscore(100) # sigma is zero + def test_properties(self): X = self.module.NormalDist(100, 15) self.assertEqual(X.mean, 100) |