|
1 | | - |
2 | 1 | import numpy as np |
3 | 2 | import pkg_resources |
4 | 3 | import os |
5 | 4 |
|
| 5 | +from protozfits import SimpleFile |
| 6 | + |
6 | 7 | example_file_path = pkg_resources.resource_filename( |
7 | 8 | 'protozfits', |
8 | 9 | os.path.join( |
|
13 | 14 | ) |
14 | 15 |
|
15 | 16 |
|
16 | | -def test_can_open_file(): |
17 | | - from protozfits import SimpleFile |
18 | | - SimpleFile(example_file_path) |
19 | | - |
20 | | - |
21 | 17 | def test_can_iterate_over_events_and_run_header(): |
22 | | - from protozfits import SimpleFile |
23 | | - f = SimpleFile(example_file_path) |
24 | 18 |
|
25 | | - camera_config = next(f.CameraConfig) |
26 | | - assert (camera_config.expected_pixels_id == np.arange(14)).all() |
| 19 | + with SimpleFile(example_file_path) as f: |
| 20 | + |
| 21 | + camera_config = next(f.CameraConfig) |
| 22 | + assert (camera_config.expected_pixels_id == np.arange(14)).all() |
27 | 23 |
|
28 | | - for event in f.Events: |
29 | | - assert event.waveform.shape == (1120,) |
30 | | - assert event.pixel_status.shape == (14,) |
31 | | - assert event.lstcam.first_capacitor_id.shape == (16,) |
32 | | - assert event.lstcam.counters.shape == (44,) |
| 24 | + for i, event in enumerate(f.Events): |
| 25 | + assert event.event_id == i + 1 |
| 26 | + assert event.waveform.shape == (1120,) |
| 27 | + assert event.pixel_status.shape == (14,) |
| 28 | + assert event.lstcam.first_capacitor_id.shape == (16,) |
| 29 | + assert event.lstcam.counters.shape == (44,) |
0 commit comments