9
9
from textwrap import dedent
10
10
11
11
import numpy as np
12
- import scipy . special
12
+ from scipy import special
13
13
14
14
from pytensor .configdefaults import config
15
15
from pytensor .gradient import grad_not_implemented , grad_undefined
@@ -52,7 +52,7 @@ class Erf(UnaryScalarOp):
52
52
nfunc_spec = ("scipy.special.erf" , 1 , 1 )
53
53
54
54
def impl (self , x ):
55
- return scipy . special .erf (x )
55
+ return special .erf (x )
56
56
57
57
def L_op (self , inputs , outputs , grads ):
58
58
(x ,) = inputs
@@ -86,7 +86,7 @@ class Erfc(UnaryScalarOp):
86
86
nfunc_spec = ("scipy.special.erfc" , 1 , 1 )
87
87
88
88
def impl (self , x ):
89
- return scipy . special .erfc (x )
89
+ return special .erfc (x )
90
90
91
91
def L_op (self , inputs , outputs , grads ):
92
92
(x ,) = inputs
@@ -113,7 +113,7 @@ def c_code(self, node, name, inp, out, sub):
113
113
return f"{ z } = erfc(({ cast } ){ x } );"
114
114
115
115
116
- # scipy. special.erfc don't support complex. Why?
116
+ # special.erfc don't support complex. Why?
117
117
erfc = Erfc (upgrade_to_float_no_complex , name = "erfc" )
118
118
119
119
@@ -135,7 +135,7 @@ class Erfcx(UnaryScalarOp):
135
135
nfunc_spec = ("scipy.special.erfcx" , 1 , 1 )
136
136
137
137
def impl (self , x ):
138
- return scipy . special .erfcx (x )
138
+ return special .erfcx (x )
139
139
140
140
def L_op (self , inputs , outputs , grads ):
141
141
(x ,) = inputs
@@ -191,7 +191,7 @@ class Erfinv(UnaryScalarOp):
191
191
nfunc_spec = ("scipy.special.erfinv" , 1 , 1 )
192
192
193
193
def impl (self , x ):
194
- return scipy . special .erfinv (x )
194
+ return special .erfinv (x )
195
195
196
196
def L_op (self , inputs , outputs , grads ):
197
197
(x ,) = inputs
@@ -226,7 +226,7 @@ class Erfcinv(UnaryScalarOp):
226
226
nfunc_spec = ("scipy.special.erfcinv" , 1 , 1 )
227
227
228
228
def impl (self , x ):
229
- return scipy . special .erfcinv (x )
229
+ return special .erfcinv (x )
230
230
231
231
def L_op (self , inputs , outputs , grads ):
232
232
(x ,) = inputs
@@ -261,7 +261,7 @@ class Owens_t(BinaryScalarOp):
261
261
nfunc_spec = ("scipy.special.owens_t" , 2 , 1 )
262
262
263
263
def impl (self , h , a ):
264
- return scipy . special .owens_t (h , a )
264
+ return special .owens_t (h , a )
265
265
266
266
def grad (self , inputs , grads ):
267
267
(h , a ) = inputs
@@ -286,7 +286,7 @@ class Gamma(UnaryScalarOp):
286
286
nfunc_spec = ("scipy.special.gamma" , 1 , 1 )
287
287
288
288
def impl (self , x ):
289
- return scipy . special .gamma (x )
289
+ return special .gamma (x )
290
290
291
291
def L_op (self , inputs , outputs , gout ):
292
292
(x ,) = inputs
@@ -321,7 +321,7 @@ class GammaLn(UnaryScalarOp):
321
321
nfunc_spec = ("scipy.special.gammaln" , 1 , 1 )
322
322
323
323
def impl (self , x ):
324
- return scipy . special .gammaln (x )
324
+ return special .gammaln (x )
325
325
326
326
def L_op (self , inputs , outputs , grads ):
327
327
(x ,) = inputs
@@ -361,7 +361,7 @@ class Psi(UnaryScalarOp):
361
361
nfunc_spec = ("scipy.special.psi" , 1 , 1 )
362
362
363
363
def impl (self , x ):
364
- return scipy . special .psi (x )
364
+ return special .psi (x )
365
365
366
366
def L_op (self , inputs , outputs , grads ):
367
367
(x ,) = inputs
@@ -448,7 +448,7 @@ class TriGamma(UnaryScalarOp):
448
448
"""
449
449
450
450
def impl (self , x ):
451
- return scipy . special .polygamma (1 , x )
451
+ return special .polygamma (1 , x )
452
452
453
453
def L_op (self , inputs , outputs , outputs_gradients ):
454
454
(x ,) = inputs
@@ -547,7 +547,7 @@ def output_types_preference(n_type, x_type):
547
547
return upgrade_to_float_no_complex (x_type )
548
548
549
549
def impl (self , n , x ):
550
- return scipy . special .polygamma (n , x )
550
+ return special .polygamma (n , x )
551
551
552
552
def L_op (self , inputs , outputs , output_gradients ):
553
553
(n , x ) = inputs
@@ -574,7 +574,7 @@ class GammaInc(BinaryScalarOp):
574
574
nfunc_spec = ("scipy.special.gammainc" , 2 , 1 )
575
575
576
576
def impl (self , k , x ):
577
- return scipy . special .gammainc (k , x )
577
+ return special .gammainc (k , x )
578
578
579
579
def grad (self , inputs , grads ):
580
580
(k , x ) = inputs
@@ -621,7 +621,7 @@ class GammaIncC(BinaryScalarOp):
621
621
nfunc_spec = ("scipy.special.gammaincc" , 2 , 1 )
622
622
623
623
def impl (self , k , x ):
624
- return scipy . special .gammaincc (k , x )
624
+ return special .gammaincc (k , x )
625
625
626
626
def grad (self , inputs , grads ):
627
627
(k , x ) = inputs
@@ -668,7 +668,7 @@ class GammaIncInv(BinaryScalarOp):
668
668
nfunc_spec = ("scipy.special.gammaincinv" , 2 , 1 )
669
669
670
670
def impl (self , k , x ):
671
- return scipy . special .gammaincinv (k , x )
671
+ return special .gammaincinv (k , x )
672
672
673
673
def grad (self , inputs , grads ):
674
674
(k , x ) = inputs
@@ -693,7 +693,7 @@ class GammaIncCInv(BinaryScalarOp):
693
693
nfunc_spec = ("scipy.special.gammainccinv" , 2 , 1 )
694
694
695
695
def impl (self , k , x ):
696
- return scipy . special .gammainccinv (k , x )
696
+ return special .gammainccinv (k , x )
697
697
698
698
def grad (self , inputs , grads ):
699
699
(k , x ) = inputs
@@ -928,7 +928,7 @@ class GammaU(BinaryScalarOp):
928
928
# Note there is no basic SciPy version so no nfunc_spec.
929
929
930
930
def impl (self , k , x ):
931
- return scipy . special .gammaincc (k , x ) * scipy . special .gamma (k )
931
+ return special .gammaincc (k , x ) * special .gamma (k )
932
932
933
933
def c_support_code (self , ** kwargs ):
934
934
return (C_CODE_PATH / "gamma.c" ).read_text (encoding = "utf-8" )
@@ -960,7 +960,7 @@ class GammaL(BinaryScalarOp):
960
960
# Note there is no basic SciPy version so no nfunc_spec.
961
961
962
962
def impl (self , k , x ):
963
- return scipy . special .gammainc (k , x ) * scipy . special .gamma (k )
963
+ return special .gammainc (k , x ) * special .gamma (k )
964
964
965
965
def c_support_code (self , ** kwargs ):
966
966
return (C_CODE_PATH / "gamma.c" ).read_text (encoding = "utf-8" )
@@ -992,7 +992,7 @@ class Jv(BinaryScalarOp):
992
992
nfunc_spec = ("scipy.special.jv" , 2 , 1 )
993
993
994
994
def impl (self , v , x ):
995
- return scipy . special .jv (v , x )
995
+ return special .jv (v , x )
996
996
997
997
def grad (self , inputs , grads ):
998
998
v , x = inputs
@@ -1017,7 +1017,7 @@ class J1(UnaryScalarOp):
1017
1017
nfunc_spec = ("scipy.special.j1" , 1 , 1 )
1018
1018
1019
1019
def impl (self , x ):
1020
- return scipy . special .j1 (x )
1020
+ return special .j1 (x )
1021
1021
1022
1022
def grad (self , inputs , grads ):
1023
1023
(x ,) = inputs
@@ -1044,7 +1044,7 @@ class J0(UnaryScalarOp):
1044
1044
nfunc_spec = ("scipy.special.j0" , 1 , 1 )
1045
1045
1046
1046
def impl (self , x ):
1047
- return scipy . special .j0 (x )
1047
+ return special .j0 (x )
1048
1048
1049
1049
def grad (self , inp , grads ):
1050
1050
(x ,) = inp
@@ -1071,7 +1071,7 @@ class Iv(BinaryScalarOp):
1071
1071
nfunc_spec = ("scipy.special.iv" , 2 , 1 )
1072
1072
1073
1073
def impl (self , v , x ):
1074
- return scipy . special .iv (v , x )
1074
+ return special .iv (v , x )
1075
1075
1076
1076
def grad (self , inputs , grads ):
1077
1077
v , x = inputs
@@ -1096,7 +1096,7 @@ class I1(UnaryScalarOp):
1096
1096
nfunc_spec = ("scipy.special.i1" , 1 , 1 )
1097
1097
1098
1098
def impl (self , x ):
1099
- return scipy . special .i1 (x )
1099
+ return special .i1 (x )
1100
1100
1101
1101
def grad (self , inputs , grads ):
1102
1102
(x ,) = inputs
@@ -1118,7 +1118,7 @@ class I0(UnaryScalarOp):
1118
1118
nfunc_spec = ("scipy.special.i0" , 1 , 1 )
1119
1119
1120
1120
def impl (self , x ):
1121
- return scipy . special .i0 (x )
1121
+ return special .i0 (x )
1122
1122
1123
1123
def grad (self , inp , grads ):
1124
1124
(x ,) = inp
@@ -1140,7 +1140,7 @@ class Ive(BinaryScalarOp):
1140
1140
nfunc_spec = ("scipy.special.ive" , 2 , 1 )
1141
1141
1142
1142
def impl (self , v , x ):
1143
- return scipy . special .ive (v , x )
1143
+ return special .ive (v , x )
1144
1144
1145
1145
def grad (self , inputs , grads ):
1146
1146
v , x = inputs
@@ -1165,7 +1165,7 @@ class Kve(BinaryScalarOp):
1165
1165
nfunc_spec = ("scipy.special.kve" , 2 , 1 )
1166
1166
1167
1167
def impl (self , v , x ):
1168
- return scipy . special .kve (v , x )
1168
+ return special .kve (v , x )
1169
1169
1170
1170
def L_op (self , inputs , outputs , output_grads ):
1171
1171
v , x = inputs
@@ -1195,7 +1195,7 @@ class Sigmoid(UnaryScalarOp):
1195
1195
nfunc_spec = ("scipy.special.expit" , 1 , 1 )
1196
1196
1197
1197
def impl (self , x ):
1198
- return scipy . special .expit (x )
1198
+ return special .expit (x )
1199
1199
1200
1200
def grad (self , inp , grads ):
1201
1201
(x ,) = inp
@@ -1362,7 +1362,7 @@ class BetaInc(ScalarOp):
1362
1362
nfunc_spec = ("scipy.special.betainc" , 3 , 1 )
1363
1363
1364
1364
def impl (self , a , b , x ):
1365
- return scipy . special .betainc (a , b , x )
1365
+ return special .betainc (a , b , x )
1366
1366
1367
1367
def grad (self , inp , grads ):
1368
1368
a , b , x = inp
@@ -1622,7 +1622,7 @@ class BetaIncInv(ScalarOp):
1622
1622
nfunc_spec = ("scipy.special.betaincinv" , 3 , 1 )
1623
1623
1624
1624
def impl (self , a , b , x ):
1625
- return scipy . special .betaincinv (a , b , x )
1625
+ return special .betaincinv (a , b , x )
1626
1626
1627
1627
def grad (self , inputs , grads ):
1628
1628
(a , b , x ) = inputs
@@ -1661,7 +1661,7 @@ class Hyp2F1(ScalarOp):
1661
1661
nfunc_spec = ("scipy.special.hyp2f1" , 4 , 1 )
1662
1662
1663
1663
def impl (self , a , b , c , z ):
1664
- return scipy . special .hyp2f1 (a , b , c , z )
1664
+ return special .hyp2f1 (a , b , c , z )
1665
1665
1666
1666
def grad (self , inputs , grads ):
1667
1667
a , b , c , z = inputs
0 commit comments