|
1 | | -from pynwb.behavior import SpatialSeries |
| 1 | +from pynwb.behavior import SpatialSeries, CompassDirection |
2 | 2 | import numpy as np |
3 | 3 |
|
4 | | -from nwbinspector import InspectorMessage, Importance, check_spatial_series_dims |
| 4 | +from nwbinspector import InspectorMessage, Importance |
| 5 | +from nwbinspector.checks.behavior import check_compass_direction_unit, check_spatial_series_dims |
5 | 6 |
|
6 | 7 |
|
7 | 8 | def test_check_spatial_series_dims(): |
@@ -47,3 +48,36 @@ def test_pass_check_spatial_series_dims_1d(): |
47 | 48 | ) |
48 | 49 |
|
49 | 50 | assert check_spatial_series_dims(spatial_series) is None |
| 51 | + |
| 52 | + |
| 53 | +def test_trigger_check_compass_direction_unit(): |
| 54 | + obj = CompassDirection( |
| 55 | + spatial_series=SpatialSeries( |
| 56 | + name="SpatialSeries", |
| 57 | + description="description", |
| 58 | + data=np.ones((10,)), |
| 59 | + rate=3.0, |
| 60 | + reference_frame="reference_frame", |
| 61 | + ) |
| 62 | + ) |
| 63 | + |
| 64 | + assert ( |
| 65 | + check_compass_direction_unit(obj)[0].message == f"SpatialSeries objects inside a CompassDirection object " |
| 66 | + f"should be angular and should have a unit of 'degrees' or 'radians', but 'SpatialSeries' has units 'meters'." |
| 67 | + ) |
| 68 | + |
| 69 | + |
| 70 | +def test_pass_check_compass_direction_unit(): |
| 71 | + for unit in ("radians", "degrees"): |
| 72 | + obj = CompassDirection( |
| 73 | + spatial_series=SpatialSeries( |
| 74 | + name="SpatialSeries", |
| 75 | + description="description", |
| 76 | + data=np.ones((10,)), |
| 77 | + rate=3.0, |
| 78 | + reference_frame="reference_frame", |
| 79 | + unit=unit, |
| 80 | + ) |
| 81 | + ) |
| 82 | + |
| 83 | + assert check_compass_direction_unit(obj) is None |
0 commit comments