|
1 | 1 | import platform |
2 | 2 | import json |
3 | 3 | from unittest import TestCase |
| 4 | +from packaging import version |
4 | 5 |
|
5 | 6 | import numpy as np |
6 | 7 | from hdmf.common import DynamicTable, DynamicTableRegion |
|
17 | 18 | check_single_row, |
18 | 19 | check_table_values_for_dict, |
19 | 20 | ) |
| 21 | +from nwbinspector.utils import get_package_version |
20 | 22 |
|
21 | 23 |
|
22 | 24 | class TestCheckDynamicTableRegion(TestCase): |
@@ -227,26 +229,37 @@ def test_check_single_row_pass(): |
227 | 229 |
|
228 | 230 | def test_check_single_row_ignore_units(): |
229 | 231 | table = Units( |
230 | | - name="Units", # default name when building through nwbfile |
231 | | - ) |
| 232 | + name="Units", |
| 233 | + ) # default name when building through nwbfile |
232 | 234 | table.add_unit(spike_times=[1, 2, 3]) |
233 | 235 | assert check_single_row(table=table) is None |
234 | 236 |
|
235 | 237 |
|
236 | 238 | def test_check_single_row_ignore_electrodes(): |
237 | 239 | table = ElectrodeTable( |
238 | | - name="electrodes", # default name when building through nwbfile |
239 | | - ) |
240 | | - table.add_row( |
241 | | - x=np.nan, |
242 | | - y=np.nan, |
243 | | - z=np.nan, |
244 | | - imp=np.nan, |
245 | | - location="unknown", |
246 | | - filtering="unknown", |
247 | | - group=ElectrodeGroup(name="test_group", description="", device=Device(name="test_device"), location="unknown"), |
248 | | - group_name="test_group", |
249 | | - ) |
| 240 | + name="electrodes", |
| 241 | + ) # default name when building through nwbfile |
| 242 | + if get_package_version(name="pynwb") >= version.Version("2.1.0"): |
| 243 | + table.add_row( |
| 244 | + location="unknown", |
| 245 | + group=ElectrodeGroup( |
| 246 | + name="test_group", description="", device=Device(name="test_device"), location="unknown" |
| 247 | + ), |
| 248 | + group_name="test_group", |
| 249 | + ) |
| 250 | + else: |
| 251 | + table.add_row( |
| 252 | + x=np.nan, |
| 253 | + y=np.nan, |
| 254 | + z=np.nan, |
| 255 | + imp=np.nan, |
| 256 | + location="unknown", |
| 257 | + filtering="unknown", |
| 258 | + group=ElectrodeGroup( |
| 259 | + name="test_group", description="", device=Device(name="test_device"), location="unknown" |
| 260 | + ), |
| 261 | + group_name="test_group", |
| 262 | + ) |
250 | 263 | assert check_single_row(table=table) is None |
251 | 264 |
|
252 | 265 |
|
|
0 commit comments