micropython-ulab/tests/2d/numpy/right_shift.py
Derfies 2cde1280a4
Bitwise (#628)
* add bitwise operators

* add build to requirements

* [EDIT] - Tweaked test data and saved test results.

* Tweaked test values for and / or

* [EDIT] - Setting print options to be verbose for test comparisons.

* [EDIT] - Removed call to set_printoptions and added output from ulab instead of numpy. Of note - there seems to be a discrepancy between the numpy and ulab output for one of the left_shift cases.

* [EDIT] - Added newline at end of file for diffing purposes.

* [EDIT] - Added print options back in as output seemed truncated.

---------

Co-authored-by: Zoltán Vörös <zvoros@gmail.com>
Co-authored-by: JamieDouugh <jamie.davies@douugh.com>
2023-06-21 13:46:30 +02:00

21 lines
565 B
Python

try:
from ulab import numpy as np
except:
import numpy as np
np.set_printoptions(threshold=100)
shift_values = (
(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2),
)
dtypes = (np.uint8, np.int8, np.uint16, np.int16)
for shift_value in shift_values:
for dtype1 in dtypes:
x1 = np.array([0, 1, 2, 4, 8, 16, 32, 3, 5, 7, 11, 13], dtype=dtype1)
for dtype2 in dtypes:
x2 = np.array(shift_value, dtype=dtype2)
print(np.right_shift(x1, x2))