Skip to content

Commit 0aef4a9

Browse files
committed
add buffer tests
1 parent 6fb6f23 commit 0aef4a9

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

tests/common/buffer.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
try:
2+
import ulab as np
3+
except:
4+
import numpy as np
5+
6+
def print_as_buffer(a):
7+
print(len(memoryview(a)), list(memoryview(a)))
8+
print_as_buffer(np.ones(3))
9+
print_as_buffer(np.zeros(3))
10+
print_as_buffer(np.eye(4))
11+
print_as_buffer(np.ones(1, dtype=np.int8))
12+
print_as_buffer(np.ones(2, dtype=np.uint8))
13+
print_as_buffer(np.ones(3, dtype=np.int16))
14+
print_as_buffer(np.ones(4, dtype=np.uint16))
15+
print_as_buffer(np.ones(5, dtype=np.float))
16+
print_as_buffer(np.linspace(0, 1, 9))

tests/common/buffer.py.exp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
3 [1.0, 1.0, 1.0]
2+
3 [0.0, 0.0, 0.0]
3+
16 [1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0]
4+
1 [1]
5+
2 [1, 1]
6+
3 [1, 1, 1]
7+
4 [1, 1, 1, 1]
8+
5 [1.0, 1.0, 1.0, 1.0, 1.0]
9+
9 [0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0]

0 commit comments

Comments
 (0)