我正在尝试执行以下程序,并在结果结束时收到警告。请教我这个错误。
"/usr/lib/pymodules/python2.7/matplotlib/collections.py:548: FutureWarning:元素比较失败;相反,返回标量,但如果self._edgecolors == 'face':“,将来将执行元素比较。”
import numpy as np
import matplotlib.pyplot as plt
colorinterpolation = 50
colourMap = plt.cm.jet
x = input('Number of nodes in the vertical axis: ')
y = input('Number of nodes in the horizontal axis: ')
TI = input('Initial tempertature: ')
TN = input('Northern boundary temperature: ')
TS = input('Southern boundary temperature: ')
TE = input('Eastern boundary temperature: ')
TW = input('Western boundary temperature: ')
t = input('Number of time steps needed: ')
C1 = input('Courant number in x direction: ')
C2 = input('Courant number in y direction: ')
C3 = 1 - (2*C1) - (2*C2)
T = np.zeros((x, y))
T.fill(TI)
print 'Time step 0'
print T
for timestep in range(1, t+1):
T[:1, :] = TN
T[x-1:, :] = TS
T[:, :1] = TW
T[:, y-1:] = TE
print 'Time step', timestep
for j in range(1, y-1, 1):
for i in range(1, x-1, 1):
T[i, j] = T[i, j]*C3 + C1*(T[i+1,j] + T[i-1, j]) + C2*(T[i, j+1] + T[i, j-1])
print T
plt.contourf(np.flipud(T), colorinterpolation, cmap=colourMap)
plt.title('2-D transient heat conduction')
plt.colorbar()
plt.show()发布于 2017-04-28 17:10:45
请记住,这实际上不是一个错误,只是一个警告。所以你可以忽略它,如果不是这样的话,所有的事情都像预期的那样工作。它可能是由版本之间的某些不匹配引起的,参见这里
如果您真的想消除这个警告,可以考虑更新numpy和matplotlib。
https://stackoverflow.com/questions/43671582
复制相似问题