在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python 程序測試不通過

python 程序測試不通過

def shape(M):
    a = 0
    b = len(M)
    for i in M:
        if a<len(i):
            a=len(i)
    return b,a

%run -i -e test.py LinearRegressionTestCase.test_shape

 def test_shape(self):

        for _ in range(10):
            r,c = np.random.randint(low=1,high=25,size=2)
            matrix = np.random.randint(low=-10,high=10,size=(r,c))
            self.assertEqual(shape(matrix.tolist()),(r,c),'Wrong answer')

E

ERROR: test_shape (__main__.LinearRegressionTestCase)

Traceback (most recent call last):
File "C:UsersderekDesktopudacity???3linear_algebra-mastertest.py", line 14, in test_shape

self.assertEqual(shape(matrix.tolist()),(r,c),'Wrong answer')

NameError: global name 'shape' is not defined


Ran 1 test in 0.004s

FAILED (errors=1)

回答
編輯回答
爆扎

你有在test文件中importshape函數(shù)的代碼文件嗎?明顯是沒有找到函數(shù)。

2018年7月31日 12:36