如何避免 Sympify 自动删除括号 [英] How to avoid Sympify to drop parentheses automatically

查看:28
本文介绍了如何避免 Sympify 自动删除括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有以下字符串

str1 = "a*(-d*(b+d)+d*(e*f))"

如果我同情它,结果是

a*(d*e*f - d*(b + d))

但我不想让 Sympy 去掉那些括号.我希望最终的表达是

But I don't want that Sympy drop those parenthesis. I want the final expression to be

a*(d*(e*f) - d*(b + d))

如何做到这一点?

推荐答案

这是一个已知错误.google 代码存档中的相同错误.

That's a known bug. That same bug in the google code archive.

如果您点击 google 代码存档链接,您会找到一个补丁,可能会解决您的问题.

If you follow the google code archive link, you'll find a patch that possibly fixes your issue.

除此之外,您无能为力.问题的状态仍然是 open

Other than that, there's not much you can do. The issue's status is still open

还有这个拉取请求,您可能会觉得有趣,因为它大概可以修复问题.

There's also this pull request that you might find interesting, since it presumably fixes the issue.

这篇关于如何避免 Sympify 自动删除括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆