输入类型不支持ufunc'bitwise_or'

时间:2020-02-21 07:12:04

标签: python machine-learning bitwise-operators

我正在尝试根据以下方程式制作“ matplotlib”图:q(x)=(x ** 2)/(x + 1)

我尝试了以下代码:


def r(x):
    return (x*x) / (x+1)

while x<= -2 | x >= 0:
    pylab.plot(x, r(x), color = 'r--')

哪个告诉我错误:


TypeError                                 Traceback (most recent call last)
<ipython-input-14-387fb2375bb1> in <module>
      2     return (x*x) / (x+1)
      3 
----> 4 while x<= -2 | x >= 0:
      5     pylab.plot(x, r(x), color = 'r--')

TypeError: ufunc 'bitwise_or' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

我是python机器学习的新手,所以我对如何调试它知之甚少。

感谢您的帮助!

1 个答案:

答案 0 :(得分:0)

|是按位或运算符-您应仅使用or关键字进行逻辑选择。

Read further