File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ class LogOdds(ElemwiseTransform):
170
170
name = "logodds"
171
171
172
172
def backward (self , rv_var , rv_value ):
173
- return invlogit (rv_value , 0.0 )
173
+ return invlogit (rv_value )
174
174
175
175
def forward (self , rv_var , rv_value ):
176
176
return logit (rv_value )
Original file line number Diff line number Diff line change @@ -200,9 +200,15 @@ def logdiffexp_numpy(a, b):
200
200
return a + log1mexp_numpy (b - a , negative_input = True )
201
201
202
202
203
- def invlogit (x , eps = sys . float_info . epsilon ):
203
+ def invlogit (x , eps = None ):
204
204
"""The inverse of the logit function, 1 / (1 + exp(-x))."""
205
- return (1.0 - 2.0 * eps ) / (1.0 + at .exp (- x )) + eps
205
+ if eps is not None :
206
+ warnings .warn (
207
+ "pymc3.math.invlogit no longer supports the ``eps`` argument and it will be ignored." ,
208
+ DeprecationWarning ,
209
+ stacklevel = 2 ,
210
+ )
211
+ return at .sigmoid (x )
206
212
207
213
208
214
def logbern (log_p ):
Original file line number Diff line number Diff line change 23
23
LogDet ,
24
24
cartesian ,
25
25
expand_packed_triangular ,
26
+ invlogit ,
26
27
invprobit ,
27
28
kron_dot ,
28
29
kron_solve_lower ,
@@ -250,3 +251,17 @@ def test_expand_packed_triangular():
250
251
assert np .all (expand_upper .eval ({packed : upper_packed }) == upper )
251
252
assert np .all (expand_diag_lower .eval ({packed : lower_packed }) == floatX (np .diag (vals )))
252
253
assert np .all (expand_diag_upper .eval ({packed : upper_packed }) == floatX (np .diag (vals )))
254
+
255
+
256
+ def test_invlogit_deprecation_warning ():
257
+ with pytest .warns (
258
+ DeprecationWarning ,
259
+ match = "pymc3.math.invlogit no longer supports the" ,
260
+ ):
261
+ res = invlogit (np .array (- 750.0 ), 1e-5 ).eval ()
262
+
263
+ with pytest .warns (None ) as record :
264
+ res_zero_eps = invlogit (np .array (- 750.0 )).eval ()
265
+ assert not record
266
+
267
+ assert np .isclose (res , res_zero_eps )
You can’t perform that action at this time.
0 commit comments