![](/img/trans.png)
[英]What's wrong with my code? I can run this fine on my vscode but it won't work on heroku, the prob comes from this code
[英]This code ran fine in Colab but didn't in Jupyter, what's wrong?
我是新手,非常迷茫。 代码在 Colab 中运行良好,但在 Jupyter 中运行良好,错误消息说
<ipython-input-39-857dd8605500>:1: RuntimeWarning: invalid value encountered in sqrt
def f(x, y): return np.sqrt(9-x**2-y**2)
<ipython-input-39-857dd8605500>:8: UserWarning: Z contains NaN values. This may result in rendering artifacts.
ax.plot_surface(X, Y, f(X, Y))
这是代码:
def f(x, y): return np.sqrt(9 - x**2 - y**2)
x = np.linspace(-4, 4, 100)
y = np.linspace(-2, 2, 100)
X, Y = np.meshgrid(x, y)
ax = plt.axes(projection = '3d')
ax.plot_surface(X, Y, f(X, Y))
您的函数在平方根函数内创建负值。 这不是用实数定义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.