Skip to content

Commit b4f5490

Browse files
authored
Add vector 2-norm axis = 0 test case
1 parent 1754a2e commit b4f5490

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

tests/numpy/linalg.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,18 @@
106106
ref_result = 16.881943016134134
107107
print(math.isclose(result, ref_result, rel_tol=1E-6, abs_tol=1E-6))
108108

109-
a = np.array([[0, 1, 2], [5, 4, 8], [4, 4, 8] ], dtype=np.int16)
110-
result = (np.linalg.norm(a,axis=1))
111-
ref_result = np.array([2.236068, 10.24695, 9.797959]) #Problem when element > 10?
109+
110+
a = np.array([[0, 1, 2], [3, 4 ,5], [5, 4, 8], [4, 4, 8] ], dtype=np.int16)
111+
result = (np.linalg.norm(a,axis=0)) # fails on low tolerance when result >10?
112+
ref_result = np.array([7.071068, 7.0, 12.52996])
112113
for i in range(3):
113114
print(math.isclose(result[i], ref_result[i], rel_tol=1E-6, abs_tol=1E-6))
115+
116+
a = np.array([[0, 1, 2], [3, 4 ,5], [5, 4, 8], [4, 4, 8] ], dtype=np.int16)
117+
result = (np.linalg.norm(a,axis=1)). # fails on low tolerance when result >10?
118+
ref_result = np.array([2.236068, 7.071068, 10.24695, 9.797959])
119+
for i in range(4):
120+
print(math.isclose(result[i], ref_result[i], rel_tol=1E-6, abs_tol=1E-6))
114121

115122
if use_ulab:
116123
print(np.linalg.trace(np.eye(3)))

0 commit comments

Comments
 (0)