Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
60c2d925
提交
60c2d925
authored
2月 12, 2025
作者:
Ricardo Vieira
提交者:
Ricardo Vieira
2月 12, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecate Chi2SF ScalarOp
上级
ffdde1cd
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
2 行增加
和
61 行删除
+2
-61
math.py
pytensor/scalar/math.py
+0
-45
inplace.py
pytensor/tensor/inplace.py
+0
-5
math.py
pytensor/tensor/math.py
+2
-1
test_math_scipy.py
tests/tensor/test_math_scipy.py
+0
-10
没有找到文件。
pytensor/scalar/math.py
浏览文件 @
60c2d925
...
@@ -40,7 +40,6 @@ from pytensor.scalar.basic import (
...
@@ -40,7 +40,6 @@ from pytensor.scalar.basic import (
true_div
,
true_div
,
upcast
,
upcast
,
upgrade_to_float
,
upgrade_to_float
,
upgrade_to_float64
,
upgrade_to_float_no_complex
,
upgrade_to_float_no_complex
,
)
)
from
pytensor.scalar.basic
import
abs
as
scalar_abs
from
pytensor.scalar.basic
import
abs
as
scalar_abs
...
@@ -592,50 +591,6 @@ class PolyGamma(BinaryScalarOp):
...
@@ -592,50 +591,6 @@ class PolyGamma(BinaryScalarOp):
polygamma
=
PolyGamma
(
name
=
"polygamma"
)
polygamma
=
PolyGamma
(
name
=
"polygamma"
)
class
Chi2SF
(
BinaryScalarOp
):
"""
Compute (1 - chi2_cdf(x))
ie. chi2 pvalue (chi2 'survival function')
"""
nfunc_spec
=
(
"scipy.stats.chi2.sf"
,
2
,
1
)
@staticmethod
def
st_impl
(
x
,
k
):
return
scipy
.
stats
.
chi2
.
sf
(
x
,
k
)
def
impl
(
self
,
x
,
k
):
return
Chi2SF
.
st_impl
(
x
,
k
)
def
c_support_code
(
self
,
**
kwargs
):
return
(
C_CODE_PATH
/
"gamma.c"
)
.
read_text
(
encoding
=
"utf-8"
)
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
x
,
k
=
inp
(
z
,)
=
out
if
node
.
inputs
[
0
]
.
type
in
float_types
:
dtype
=
"npy_"
+
node
.
outputs
[
0
]
.
dtype
return
f
"""{z} =
({dtype}) 1 - GammaP({k}/2., {x}/2.);"""
raise
NotImplementedError
(
"only floatingpoint is implemented"
)
def
__eq__
(
self
,
other
):
return
type
(
self
)
is
type
(
other
)
def
__hash__
(
self
):
return
hash
(
type
(
self
))
def
c_code_cache_version
(
self
):
v
=
super
()
.
c_code_cache_version
()
if
v
:
return
(
2
,
*
v
)
else
:
return
v
chi2sf
=
Chi2SF
(
upgrade_to_float64
,
name
=
"chi2sf"
)
class
GammaInc
(
BinaryScalarOp
):
class
GammaInc
(
BinaryScalarOp
):
"""
"""
Compute the regularized lower gamma function (P).
Compute the regularized lower gamma function (P).
...
...
pytensor/tensor/inplace.py
浏览文件 @
60c2d925
...
@@ -258,11 +258,6 @@ def tri_gamma_inplace(a):
...
@@ -258,11 +258,6 @@ def tri_gamma_inplace(a):
"""second derivative of the log gamma function"""
"""second derivative of the log gamma function"""
@scalar_elemwise
def
chi2sf_inplace
(
x
,
k
):
"""chi squared survival function"""
@scalar_elemwise
@scalar_elemwise
def
gammainc_inplace
(
k
,
x
):
def
gammainc_inplace
(
k
,
x
):
"""regularized lower gamma function (P)"""
"""regularized lower gamma function (P)"""
...
...
pytensor/tensor/math.py
浏览文件 @
60c2d925
...
@@ -1154,9 +1154,10 @@ def polygamma(n, x):
...
@@ -1154,9 +1154,10 @@ def polygamma(n, x):
"""Polygamma function of order n evaluated at x"""
"""Polygamma function of order n evaluated at x"""
@scalar_elemwise
def
chi2sf
(
x
,
k
):
def
chi2sf
(
x
,
k
):
"""chi squared survival function"""
"""chi squared survival function"""
warnings
.
warn
(
"chi2sf is deprecated. Use `gammaincc(k / 2, x / 2)` instead"
)
return
gammaincc
(
k
/
2
,
x
/
2
)
@scalar_elemwise
@scalar_elemwise
...
...
tests/tensor/test_math_scipy.py
浏览文件 @
60c2d925
...
@@ -306,16 +306,6 @@ TestChi2SFBroadcast = makeBroadcastTester(
...
@@ -306,16 +306,6 @@ TestChi2SFBroadcast = makeBroadcastTester(
name
=
"Chi2SF"
,
name
=
"Chi2SF"
,
)
)
TestChi2SFInplaceBroadcast
=
makeBroadcastTester
(
op
=
inplace
.
chi2sf_inplace
,
expected
=
expected_chi2sf
,
good
=
_good_broadcast_unary_chi2sf
,
eps
=
2e-10
,
mode
=
mode_no_scipy
,
inplace
=
True
,
name
=
"Chi2SF"
,
)
rng
=
np
.
random
.
default_rng
(
seed
=
utt
.
fetch_seed
())
rng
=
np
.
random
.
default_rng
(
seed
=
utt
.
fetch_seed
())
_good_broadcast_binary_gamma
=
dict
(
_good_broadcast_binary_gamma
=
dict
(
normal
=
(
normal
=
(
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论