我正在尝试执行以下程序,并且我在结果结束时收到警告。请告诉我有关错误的信息。
“/ usr / lib / pymodules / python2.7 / matplotlib / collections.py:548:UmerwayWarning:元素比较失败;改为返回标量,但将来会执行元素比较 如果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()
答案 0 :(得分:1)
请注意,这实际上并不是一个错误,只是一个警告。所以你可以忽略它,否则一切都按预期工作。这可能是由版本之间的某些不匹配引起的,例如, here
如果你真的想要摆脱这个警告,你可以考虑更新numpy和matplotlib。