def test_rawreader_can_iterate(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':Events') for i in range(rawzfitsreader.getNumRows()): event = L0_pb2.CameraEvent() event.ParseFromString(rawzfitsreader.readEvent())
def test_rawreader_can_work_with_absolute_path(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':Events') raw = rawzfitsreader.readEvent() assert rawzfitsreader.getNumRows() == EVENTS_IN_EXAMPLE_FILE event = L0_pb2.CameraEvent() event.ParseFromString(raw)
def test_import_open_read_and_parse(): from protozfits import rawzfitsreader from protozfits import L0_pb2 relative_test_file_path = os.path.relpath(example_file_path) rawzfitsreader.open(relative_test_file_path + ':Events') raw = rawzfitsreader.readEvent() event = L0_pb2.CameraEvent() event.ParseFromString(raw)
def test_rawreader_can_iterate(): from protozfits import rawzfits from protozfits import L0_pb2 ifits = rawzfits.ProtobufIFits( fname=example_file_path, tablename="Events" ) for i in range(ifits.num_rows()): event = L0_pb2.CameraEvent() event.ParseFromString(ifits.read_event())
def test_import_open_read_and_parse(): from protozfits import rawzfits from protozfits import L0_pb2 relative_test_file_path = os.path.relpath(example_file_path) ifits = rawzfits.ProtobufIFits( fname=relative_test_file_path, tablename="Events" ) raw = ifits.read_event() event = L0_pb2.CameraEvent() event.ParseFromString(raw)
def test_ProtobufIFits_read_a_given_event(): from protozfits import rawzfits from protozfits import L0_pb2 ifits = rawzfits.ProtobufIFits( fname=example_file_path, tablename="Events" ) for random_id in [7, 1, 10, 2]: event = L0_pb2.CameraEvent() event.ParseFromString(ifits.read_a_given_event(random_id)) assert event.eventNumber == FIRST_EVENT_NUMBER + random_id - 1
def test_rawreader_can_work_with_absolute_path(): from protozfits import rawzfits from protozfits import L0_pb2 ifits = rawzfits.ProtobufIFits( fname=example_file_path, tablename="Events" ) assert ifits.num_rows() == EVENTS_IN_EXAMPLE_FILE raw = ifits.read_event() event = L0_pb2.CameraEvent() event.ParseFromString(raw)
def test_no_crash_when_iterating_too_far(): from protozfits import rawzfitsreader from protozfits import L0_pb2 rawzfitsreader.open(example_file_path + ':Events') for i in range(rawzfitsreader.getNumRows()): event = L0_pb2.CameraEvent() event.ParseFromString(rawzfitsreader.readEvent()) # At this point we iterated through the entire file. # In version 0.43 we got a crash (seg fault or so) when iterating too # far. This test should ensure this behaviour is fixed in 0.44 with pytest.raises(EOFError): rawzfitsreader.readEvent()
def test_no_crash_when_iterating_too_far(): from protozfits import rawzfits from protozfits import L0_pb2 ifits = rawzfits.ProtobufIFits( fname=example_file_path, tablename="Events" ) for i in range(ifits.num_rows()): event = L0_pb2.CameraEvent() event.ParseFromString(ifits.read_event()) # At this point we iterated through the entire file. # In version 0.43 we got a crash (seg fault or so) when iterating too # far. This test should ensure this behaviour is fixed in 0.44 with pytest.raises(StopIteration): ifits.read_event()