Skip to content

Commit 2cb2a9a

Browse files
committed
Added tests for words_to_table without convert_enum_indices
1 parent ad05991 commit 2cb2a9a

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/test_utils.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,33 @@ def table_1_np_arrays() -> OrderedDict[str, Union[List, np.ndarray]]:
208208
)
209209

210210

211+
@pytest.fixture
212+
def table_1_np_arrays_int_enums() -> OrderedDict[str, Union[List, np.ndarray]]:
213+
# Intentionally not in panda order. Whatever types the np arrays are,
214+
# the outputs from words_to_table will be uint32 or int32.
215+
return OrderedDict(
216+
{
217+
"POSITION": np.array([-5, 678, 0], dtype=np.int32),
218+
"TIME1": np.array([100, 0, 9], dtype=np.uint32),
219+
"OUTA1": np.array([0, 1, 1], dtype=np.uint8),
220+
"OUTB1": np.array([0, 0, 1], dtype=np.uint8),
221+
"OUTD1": np.array([1, 0, 1], dtype=np.uint8),
222+
"OUTE1": np.array([0, 0, 1], dtype=np.uint8),
223+
"OUTC1": np.array([0, 0, 1], dtype=np.uint8),
224+
"OUTF1": np.array([1, 0, 1], dtype=np.uint8),
225+
"TIME2": np.array([0, 55, 9999], dtype=np.uint32),
226+
"OUTA2": np.array([0, 0, 1], dtype=np.uint8),
227+
"OUTB2": np.array([0, 0, 1], dtype=np.uint8),
228+
"REPEATS": np.array([5, 0, 50000], dtype=np.uint32),
229+
"OUTC2": np.array([1, 1, 1], dtype=np.uint8),
230+
"OUTD2": np.array([0, 0, 1], dtype=np.uint8),
231+
"OUTE2": np.array([0, 0, 1], dtype=np.uint8),
232+
"OUTF2": np.array([1, 0, 1], dtype=np.uint8),
233+
"TRIGGER": np.array([0, 6, 0], dtype=np.uint8),
234+
}
235+
)
236+
237+
211238
@pytest.fixture
212239
def table_1_not_in_panda_order() -> OrderedDict[str, Union[List, np.ndarray]]:
213240
return OrderedDict(
@@ -351,6 +378,20 @@ def test_table_packing_unpack(
351378
np.testing.assert_array_equal(actual, expected)
352379

353380

381+
def test_table_packing_unpack_no_convert_enum(
382+
table_1_np_arrays_int_enums: OrderedDict[str, np.ndarray],
383+
table_field_info: TableFieldInfo,
384+
table_data_1: List[str],
385+
):
386+
assert table_field_info.row_words
387+
output_table = words_to_table(table_data_1, table_field_info)
388+
389+
actual: UnpackedArray
390+
for field_name, actual in output_table.items():
391+
expected = table_1_np_arrays_int_enums[str(field_name)]
392+
np.testing.assert_array_equal(actual, expected)
393+
394+
354395
def test_table_packing_pack(
355396
table_1: Dict[str, Union[List, np.ndarray]],
356397
table_field_info: TableFieldInfo,

0 commit comments

Comments
 (0)