本文整理汇总了Python中sympy.abc.a.subs函数的典型用法代码示例。如果您正苦于以下问题:Python subs函数的具体用法?Python subs怎么用?Python subs使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subs函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: s_check
def s_check(rv, ans):
# get the dummy
rv = list(rv)
d = rv[0].atoms(Dummy)
reps = zip(d, [s]*len(d))
# replace s with this dummy
rv = (rv[0].subs(reps).expand(), [(p[0].subs(reps), p[1].subs(reps))
for p in rv[1]],
[a.subs(reps) for a in rv[2]])
ans = (ans[0].subs(reps).expand(), [(p[0].subs(reps), p[1].subs(reps))
for p in ans[1]],
[a.subs(reps) for a in ans[2]])
return str(rv[0]) in [str(ans[0]), str(-ans[0])] and \
str(rv[1:]) == str(ans[1:])
开发者ID:Maihj,项目名称:sympy,代码行数:14,代码来源:test_solvers.py
示例2: test_Subs_subs
def test_Subs_subs():
assert Subs(x*y, x, x).subs(x, y) == Subs(x*y, x, y)
assert Subs(x*y, x, x + 1).subs(x, y) == \
Subs(x*y, x, y + 1)
assert Subs(x*y, y, x + 1).subs(x, y) == \
Subs(y**2, y, y + 1)
a = Subs(x*y*z, (y, x, z), (x + 1, x + z, x))
b = Subs(x*y*z, (y, x, z), (x + 1, y + z, y))
assert a.subs(x, y) == b and \
a.doit().subs(x, y) == a.subs(x, y).doit()
f = Function('f')
g = Function('g')
assert Subs(2*f(x, y) + g(x), f(x, y), 1).subs(y, 2) == Subs(
2*f(x, y) + g(x), (f(x, y), y), (1, 2))
开发者ID:asmeurer,项目名称:sympy,代码行数:14,代码来源:test_subs.py
示例3: t
def t(m, a, b):
from sympy import sympify, Piecewise
a, b = sympify([a, b])
m_ = m
m = hyperexpand(m)
if not m == Piecewise((a, abs(z) < 1), (b, abs(1/z) < 1), (m_, True)):
return False
if not (m.args[0].args[0] == a and m.args[1].args[0] == b):
return False
z0 = randcplx()/10
if abs(m.subs(z, z0).n() - a.subs(z, z0).n()).n() > 1e-10:
return False
if abs(m.subs(z, 1/z0).n() - b.subs(z, 1/z0).n()).n() > 1e-10:
return False
return True
开发者ID:vprusso,项目名称:sympy,代码行数:15,代码来源:test_hyperexpand.py
注:本文中的sympy.abc.a.subs函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论