File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -762,7 +762,7 @@ def __truediv__(x1, x2):
762
762
return NormalDist (x1 .mu / x2 , x1 .sigma / fabs (x2 ))
763
763
764
764
def __pos__ (x1 ):
765
- return x1
765
+ return NormalDist ( x1 . mu , x1 . sigma )
766
766
767
767
def __neg__ (x1 ):
768
768
return NormalDist (- x1 .mu , x1 .sigma )
Original file line number Diff line number Diff line change @@ -2128,6 +2128,18 @@ def test_cdf(self):
2128
2128
with self .assertRaises (statistics .StatisticsError ):
2129
2129
Y .cdf (90 )
2130
2130
2131
+ def test_unary_operations (self ):
2132
+ NormalDist = statistics .NormalDist
2133
+ X = NormalDist (100 , 12 )
2134
+ Y = + X
2135
+ self .assertIsNot (X , Y )
2136
+ self .assertEqual (X .mu , Y .mu )
2137
+ self .assertEqual (X .sigma , Y .sigma )
2138
+ Y = - X
2139
+ self .assertIsNot (X , Y )
2140
+ self .assertEqual (X .mu , - Y .mu )
2141
+ self .assertEqual (X .sigma , Y .sigma )
2142
+
2131
2143
def test_same_type_addition_and_subtraction (self ):
2132
2144
NormalDist = statistics .NormalDist
2133
2145
X = NormalDist (100 , 12 )
You can’t perform that action at this time.
0 commit comments