22Module for testing functions specific to tables containing DynamicTableRegion columns
33"""
44
5+ import warnings
56import numpy as np
67from hdmf .common import DynamicTable , AlignedDynamicTable , VectorData , DynamicTableRegion , VectorIndex
78from hdmf .testing import TestCase
@@ -139,11 +140,16 @@ def setUp(self):
139140 description = 'filter value' ,
140141 index = False )
141142 # Aligned table
142- self .aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
143- description = 'my test table' ,
144- columns = [VectorData (name = 'a1' , description = 'a1' , data = np .arange (3 )), ],
145- colnames = ['a1' , ],
146- category_tables = [self .category0 , self .category1 ])
143+ with warnings .catch_warnings ():
144+ msg = "The linked table for DynamicTableRegion '.*' does not share an ancestor with the DynamicTableRegion."
145+ warnings .filterwarnings ("ignore" , category = UserWarning , message = msg )
146+ self .aligned_table = AlignedDynamicTable (
147+ name = 'my_aligned_table' ,
148+ description = 'my test table' ,
149+ columns = [VectorData (name = 'a1' , description = 'a1' , data = np .arange (3 )), ],
150+ colnames = ['a1' , ],
151+ category_tables = [self .category0 , self .category1 ]
152+ )
147153
148154 def tearDown (self ):
149155 del self .table_level0_0
@@ -241,13 +247,16 @@ def test_get_foreign_column_in_main_and_category_table(self):
241247 columns = [VectorData (name = 'c1' , description = 'c1' , data = np .arange (4 )),
242248 DynamicTableRegion (name = 'c2' , description = 'c2' ,
243249 data = np .arange (4 ), table = temp_table0 )])
244- temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
245- description = 'my test table' ,
246- category_tables = [temp_table ],
247- colnames = ['a1' , 'a2' ],
248- columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
249- DynamicTableRegion (name = 'a2' , description = 'c2' ,
250- data = np .arange (4 ), table = temp_table )])
250+ with warnings .catch_warnings ():
251+ msg = "The linked table for DynamicTableRegion '.*' does not share an ancestor with the DynamicTableRegion."
252+ warnings .filterwarnings ("ignore" , category = UserWarning , message = msg )
253+ temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
254+ description = 'my test table' ,
255+ category_tables = [temp_table ],
256+ colnames = ['a1' , 'a2' ],
257+ columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
258+ DynamicTableRegion (name = 'a2' , description = 'c2' ,
259+ data = np .arange (4 ), table = temp_table )])
251260 # We should get both the DynamicTableRegion from the main table and the category 't1'
252261 self .assertListEqual (temp_aligned_table .get_foreign_columns (), [(None , 'a2' ), ('t1' , 'c2' )])
253262 # We should only get the column from the main table
@@ -275,12 +284,15 @@ def test_get_linked_tables_none(self):
275284 colnames = ['c1' , 'c2' ],
276285 columns = [VectorData (name = 'c1' , description = 'c1' , data = np .arange (4 )),
277286 VectorData (name = 'c2' , description = 'c2' , data = np .arange (4 ))])
278- temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
279- description = 'my test table' ,
280- category_tables = [temp_table ],
281- colnames = ['a1' , 'a2' ],
282- columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
283- VectorData (name = 'a2' , description = 'c2' , data = np .arange (4 ))])
287+ with warnings .catch_warnings ():
288+ msg = "The linked table for DynamicTableRegion '.*' does not share an ancestor with the DynamicTableRegion."
289+ warnings .filterwarnings ("ignore" , category = UserWarning , message = msg )
290+ temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
291+ description = 'my test table' ,
292+ category_tables = [temp_table ],
293+ colnames = ['a1' , 'a2' ],
294+ columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
295+ VectorData (name = 'a2' , description = 'c2' , data = np .arange (4 ))])
284296 self .assertListEqual (temp_aligned_table .get_linked_tables (), [])
285297 self .assertListEqual (temp_aligned_table .get_linked_tables (ignore_category_tables = True ), [])
286298
@@ -294,13 +306,16 @@ def test_get_linked_tables_complex_link(self):
294306 columns = [VectorData (name = 'c1' , description = 'c1' , data = np .arange (4 )),
295307 DynamicTableRegion (name = 'c2' , description = 'c2' ,
296308 data = np .arange (4 ), table = temp_table0 )])
297- temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
298- description = 'my test table' ,
299- category_tables = [temp_table ],
300- colnames = ['a1' , 'a2' ],
301- columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
302- DynamicTableRegion (name = 'a2' , description = 'c2' ,
303- data = np .arange (4 ), table = temp_table )])
309+ with warnings .catch_warnings ():
310+ msg = "The linked table for DynamicTableRegion '.*' does not share an ancestor with the DynamicTableRegion."
311+ warnings .filterwarnings ("ignore" , category = UserWarning , message = msg )
312+ temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
313+ description = 'my test table' ,
314+ category_tables = [temp_table ],
315+ colnames = ['a1' , 'a2' ],
316+ columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
317+ DynamicTableRegion (name = 'a2' , description = 'c2' ,
318+ data = np .arange (4 ), table = temp_table )])
304319 # NOTE: in this example templ_aligned_table both points to temp_table and at the
305320 # same time contains temp_table as a category. This could lead to temp_table
306321 # visited multiple times and we want to make sure this doesn't happen
@@ -326,17 +341,20 @@ def test_get_linked_tables_simple_link(self):
326341 columns = [VectorData (name = 'c1' , description = 'c1' , data = np .arange (4 )),
327342 VectorData (name = 'c2' , description = 'c2' , data = np .arange (4 ))])
328343 temp_table = DynamicTable (name = 't1' , description = 't1' ,
329- colnames = ['c1' , 'c2' ],
330- columns = [VectorData (name = 'c1' , description = 'c1' , data = np .arange (4 )),
331- DynamicTableRegion (name = 'c2' , description = 'c2' ,
332- data = np .arange (4 ), table = temp_table0 )])
333- temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
334- description = 'my test table' ,
335- category_tables = [temp_table ],
336- colnames = ['a1' , 'a2' ],
337- columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
338- DynamicTableRegion (name = 'a2' , description = 'c2' ,
339- data = np .arange (4 ), table = temp_table0 )])
344+ colnames = ['c1' , 'c2' ],
345+ columns = [VectorData (name = 'c1' , description = 'c1' , data = np .arange (4 )),
346+ DynamicTableRegion (name = 'c2' , description = 'c2' ,
347+ data = np .arange (4 ), table = temp_table0 )])
348+ with warnings .catch_warnings ():
349+ msg = "The linked table for DynamicTableRegion '.*' does not share an ancestor with the DynamicTableRegion."
350+ warnings .filterwarnings ("ignore" , category = UserWarning , message = msg )
351+ temp_aligned_table = AlignedDynamicTable (name = 'my_aligned_table' ,
352+ description = 'my test table' ,
353+ category_tables = [temp_table ],
354+ colnames = ['a1' , 'a2' ],
355+ columns = [VectorData (name = 'a1' , description = 'c1' , data = np .arange (4 )),
356+ DynamicTableRegion (name = 'a2' , description = 'c2' ,
357+ data = np .arange (4 ), table = temp_table0 )])
340358 # NOTE: in this example temp_aligned_table and temp_table both point to temp_table0
341359 # We should get both the DynamicTableRegion from the main table and the category 't1'
342360 linked_tables = temp_aligned_table .get_linked_tables ()
0 commit comments