def frame_channel_from_RP66V1(channel_object: EFLR.Object) -> FrameChannel: """Create a file format agnostic FrameChannel from an EFLR.Object (row) in a `CHANNEL` EFLR.""" return FrameChannel( ident=channel_object.name, long_name=channel_object[b'LONG-NAME'].value[0] if channel_object[b'LONG-NAME'].value is not None else b'', rep_code=channel_object[b'REPRESENTATION-CODE'].value[0], units=channel_object[b'UNITS'].value[0] if channel_object[b'UNITS'].value is not None else b'', dimensions=channel_object[b'DIMENSION'].value, # TODO: Replace this with the np.dtype directly np_dtype=RepCode.numpy_dtype(channel_object[b'REPRESENTATION-CODE'].value[0]) )
def test_numpy_dtype_raises(): with pytest.raises(RepCode.ExceptionRepCode) as err: RepCode.numpy_dtype(0) assert err.value.args[0] == 'Unsupported Representation code 0'
def test_numpy_dtype(rc, expected): assert RepCode.numpy_dtype(rc) == expected