fixed tests for new setbit, clearbit
Build on RHEL9 docker image / build (push) Successful in 4m10s
Build on RHEL8 docker image / build (push) Successful in 5m28s
Run Simulator Tests on local RHEL9 / build (push) Successful in 18m38s
Run Simulator Tests on local RHEL8 / build (push) Successful in 22m6s

This commit is contained in:
2026-07-10 09:16:36 +02:00
parent ee40de6122
commit d2c89ff4e1
2 changed files with 30 additions and 35 deletions
+12 -15
View File
@@ -1,4 +1,4 @@
from slsdet.bits import clearbit, clearbit_arr, setbit, setbit_arr
from slsdet.bits import clearbit, setbit
from slsdet import RegisterAddress
import numpy as np
@@ -15,20 +15,16 @@ def test_setbit_on_python_int():
assert r == 7
assert val == 5
def test_setbit_doesnt_change_type():
word = np.int32(5)
ret = setbit(0, word)
assert isinstance(ret, np.int32)
def test_clearbit_doesnt_change_type():
word = np.uint8(5)
ret = clearbit(0, word)
assert isinstance(ret, np.uint8)
def test_setbit_on_array_element():
arr = np.zeros(10, dtype=np.uint64)
arr[5] = setbit(0, arr[5])
@@ -38,17 +34,18 @@ def test_setbit_on_array_element():
assert arr[5] == 19 # 0b10011
assert arr[6] == 0
def test_setbit_array():
test_array = np.zeros(10, dtype=np.int32)
test_array[0:3] = setbit(0, test_array[0:3])
test_array[3:6] = setbit(1, test_array[3:6])
test_array[6:9] = setbit(2, test_array[6:9])
test_array[9] = setbit(3, test_array[9])
assert all(test_array == np.array((1, 1, 1, 2, 2, 2, 4, 4, 4, 8), dtype=np.int32))
def test_setbit_arr():
arr = np.zeros(10, dtype=np.int32)
setbit_arr(3, arr[3:9])
assert all(arr == np.array((0, 0, 0, 8, 8, 8, 8, 8, 8, 0), dtype=np.int32))
def test_clearbit_arr():
arr = np.array((5, 5, 5), dtype=np.int8)
clearbit_arr(0, arr)
assert all(arr == (4, 4, 4))
def test_clearbit_array():
test_array = 5*np.ones(3, dtype=np.int8)
test_array[:] = clearbit(0, test_array)
assert all(test_array == 4)
def test_RegisterAddress_addition():
r = RegisterAddress(0x10)