Skip to content

Commit ab964b9

Browse files
authored
Merge pull request #314 from ubIQio/ubIQio-patch-1
Add vector 2-norm test
2 parents 0ea7871 + bc7e9bb commit ab964b9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Diff for: tests/numpy/linalg.py

+12
Original file line numberDiff line numberDiff line change
@@ -106,6 +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], [3, 4 ,5], [5, 4, 8], [4, 4, 8] ], dtype=np.int16)
110+
result = (np.linalg.norm(a,axis=0)) # fails on low tolerance
111+
ref_result = np.array([7.071068, 7.0, 12.52996])
112+
for i in range(3):
113+
print(math.isclose(result[i], ref_result[i], rel_tol=1E-6, abs_tol=1E-6))
114+
115+
a = np.array([[0, 1, 2], [3, 4 ,5], [5, 4, 8], [4, 4, 8] ], dtype=np.int16)
116+
result = (np.linalg.norm(a,axis=1)) # fails on low tolerance
117+
ref_result = np.array([2.236068, 7.071068, 10.24695, 9.797959])
118+
for i in range(4):
119+
print(math.isclose(result[i], ref_result[i], rel_tol=1E-6, abs_tol=1E-6))
120+
109121
if use_ulab:
110122
print(np.linalg.trace(np.eye(3)))
111123
else:

Diff for: tests/numpy/linalg.py.exp

+7
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,11 @@ True
4444
True
4545
True
4646
True
47+
True
48+
True
49+
True
50+
True
51+
True
52+
True
53+
True
4754
3.0

0 commit comments

Comments
 (0)