11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
+ import platform
14
15
15
16
import numpy as np
16
17
import pymc as pm
@@ -50,6 +51,12 @@ class TestGenExtremeClass:
50
51
reason = "PyMC underflows earlier than scipy on float32" ,
51
52
)
52
53
def test_logp (self ):
54
+ def ref_logp (value , mu , sigma , xi ):
55
+ if 1 + xi * (value - mu ) / sigma > 0 :
56
+ return sp .genextreme .logpdf (value , c = - xi , loc = mu , scale = sigma )
57
+ else :
58
+ return - np .inf
59
+
53
60
check_logp (
54
61
GenExtreme ,
55
62
R ,
@@ -58,15 +65,23 @@ def test_logp(self):
58
65
"sigma" : Rplusbig ,
59
66
"xi" : Domain ([- 1 , - 0.99 , - 0.5 , 0 , 0.5 , 0.99 , 1 ]),
60
67
},
61
- lambda value , mu , sigma , xi : sp .genextreme .logpdf (value , c = - xi , loc = mu , scale = sigma )
62
- if 1 + xi * (value - mu ) / sigma > 0
63
- else - np .inf ,
68
+ ref_logp ,
64
69
)
65
70
66
71
if pytensor .config .floatX == "float32" :
67
72
raise Exception ("Flaky test: It passed this time, but XPASS is not allowed." )
68
73
74
+ @pytest .mark .skipif (
75
+ (pytensor .config .floatX == "float32" and platform .system () == "Windows" ),
76
+ reason = "Scipy gives different results on Windows and does not match with desired accuracy" ,
77
+ )
69
78
def test_logcdf (self ):
79
+ def ref_logcdf (value , mu , sigma , xi ):
80
+ if 1 + xi * (value - mu ) / sigma > 0 :
81
+ return sp .genextreme .logcdf (value , c = - xi , loc = mu , scale = sigma )
82
+ else :
83
+ return - np .inf
84
+
70
85
check_logcdf (
71
86
GenExtreme ,
72
87
R ,
@@ -75,9 +90,7 @@ def test_logcdf(self):
75
90
"sigma" : Rplusbig ,
76
91
"xi" : Domain ([- 1 , - 0.99 , - 0.5 , 0 , 0.5 , 0.99 , 1 ]),
77
92
},
78
- lambda value , mu , sigma , xi : sp .genextreme .logcdf (value , c = - xi , loc = mu , scale = sigma )
79
- if 1 + xi * (value - mu ) / sigma > 0
80
- else - np .inf ,
93
+ ref_logcdf ,
81
94
decimal = select_by_precision (float64 = 6 , float32 = 2 ),
82
95
)
83
96
0 commit comments