避免在同意中评估乘法乘以1

时间:2017-09-04 07:23:27

标签: python sympy

我想避免乘以1以便在同情中进行评估。我该如何实现这一目标?

我不明白为什么,乘以0可以不被评估,而乘以1总是被评估。

>>> from sympy import Symbol,Mul
>>> x = Symbol('x')
>>> Mul(1,x,evaluate=False)
x
>>> Mul(0,x,evaluate=False)
0*x

1 个答案:

答案 0 :(得分:3)

这正在https://github.com/sympy/sympy/pull/13188中进行。目前,即使evaluate = False,也会自动删除1(对于Muls)和0(对于Adds)。如果您只想将某些内容解析为(number,foo),则可以使用extension ContactDetailsViewController: UITextViewDelegate { // Resize textview depending on it's content func textViewDidChange(_ textView: UITextView) { // Get textview content size let size = textView.bounds.size let newSize = textView.sizeThatFits(CGSize(width: size.width, height: .greatestFiniteMagnitude)) // Resize the cell only when cell's size is changed if size.height != newSize.height { UIView.setAnimationsEnabled(false) tableView.beginUpdates() tableView.endUpdates() UIView.setAnimationsEnabled(true) let indexPath = IndexPath(row: 2, section: 0) tableView.scrollToRow(at: indexPath, at: .bottom, animated: false) } } ,例如expr.as_coeff_Mul()