Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ def __eq__(x1, x2):
"Two NormalDist objects are equal if their mu and sigma are both equal."
if not isinstance(x2, NormalDist):
return NotImplemented
return (x1._mu, x2._sigma) == (x2._mu, x2._sigma)
return x1._mu == x2._mu and x1._sigma == x2._sigma

def __hash__(self):
"NormalDist objects hash equal if their mu and sigma are both equal."
Expand Down
4 changes: 4 additions & 0 deletions Lib/test/test_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2651,9 +2651,13 @@ def test_equality(self):
nd2 = NormalDist(2, 4)
nd3 = NormalDist()
nd4 = NormalDist(2, 4)
nd5 = NormalDist(2, 8)
nd6 = NormalDist(8, 4)
self.assertNotEqual(nd1, nd2)
self.assertEqual(nd1, nd3)
self.assertEqual(nd2, nd4)
self.assertNotEqual(nd2, nd5)
self.assertNotEqual(nd2, nd6)

# Test NotImplemented when types are different
class A:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed erroneous equality comparison in statistics.NormalDist().