@@ -43,7 +43,11 @@ def test_layout_init(layout_7t_trt):
4343 ])
4444def test_index_metadata (index_metadata , query , result , mock_config ):
4545 data_dir = join (get_test_data_path (), '7t_trt' )
46- layout = BIDSLayout (data_dir , index_metadata = index_metadata , ** query )
46+ layout = BIDSLayout (
47+ data_dir ,
48+ indexer = BIDSLayoutIndexer (index_metadata = index_metadata ),
49+ ** query
50+ )
4751 sample_file = layout .get (task = 'rest' , extension = '.nii.gz' ,
4852 acquisition = 'fullbrain' )[0 ]
4953 metadata = sample_file .get_metadata ()
@@ -425,22 +429,39 @@ def test_nested_include_exclude():
425429 target1 = join (data_dir , 'models' , 'ds-005_type-test_model.json' )
426430 target2 = join (data_dir , 'models' , 'extras' , 'ds-005_type-test_model.json' )
427431
428- # Nest a directory exclusion within an inclusion
429- layout = BIDSLayout (data_dir , validate = True , force_index = ['models' ],
430- ignore = [os .path .join ('models' , 'extras' )])
431- assert layout .get_file (target1 )
432- assert not layout .get_file (target2 )
433-
434432 # Nest a directory inclusion within an exclusion
435- layout = BIDSLayout (data_dir , validate = True , ignore = ['models' ],
436- force_index = [os .path .join ('models' , 'extras' )])
433+ layout = BIDSLayout (
434+ data_dir ,
435+ indexer = BIDSLayoutIndexer (
436+ validate = True ,
437+ force_index = [os .path .join ('models' , 'extras' )],
438+ ignore = ['models' ],
439+ ),
440+ )
437441 assert not layout .get_file (target1 )
438442 assert layout .get_file (target2 )
439443
444+ # Nest a directory exclusion within an inclusion
445+ layout = BIDSLayout (
446+ data_dir ,
447+ indexer = BIDSLayoutIndexer (
448+ validate = True ,
449+ force_index = ['models' ],
450+ ignore = [os .path .join ('models' , 'extras' )],
451+ ),
452+ )
453+ assert layout .get_file (target1 )
454+ assert not layout .get_file (target2 )
455+
440456 # Force file inclusion despite directory-level exclusion
441- models = ['models' , target2 ]
442- layout = BIDSLayout (data_dir , validate = True , force_index = models ,
443- ignore = [os .path .join ('models' , 'extras' )])
457+ layout = BIDSLayout (
458+ data_dir ,
459+ indexer = BIDSLayoutIndexer (
460+ validate = True ,
461+ force_index = ['models' , target2 ],
462+ ignore = [os .path .join ('models' , 'extras' )],
463+ ),
464+ )
444465 assert layout .get_file (target1 )
445466 assert layout .get_file (target2 )
446467
@@ -453,11 +474,17 @@ def test_nested_include_exclude_with_regex():
453474 target1 = join (data_dir , 'models' , 'ds-005_type-test_model.json' )
454475 target2 = join (data_dir , 'models' , 'extras' , 'ds-005_type-test_model.json' )
455476
456- layout = BIDSLayout (data_dir , ignore = [patt2 ], force_index = [patt1 ])
477+ layout = BIDSLayout (
478+ data_dir ,
479+ indexer = BIDSLayoutIndexer (ignore = [patt2 ], force_index = [patt1 ])
480+ )
457481 assert layout .get_file (target1 )
458482 assert not layout .get_file (target2 )
459483
460- layout = BIDSLayout (data_dir , ignore = [patt1 ], force_index = [patt2 ])
484+ layout = BIDSLayout (
485+ data_dir ,
486+ indexer = BIDSLayoutIndexer (ignore = [patt1 ], force_index = [patt2 ])
487+ )
461488 assert not layout .get_file (target1 )
462489 assert layout .get_file (target2 )
463490
@@ -848,11 +875,11 @@ def test_indexer_patterns(fname):
848875 root = Path ("/home/user/.cache/data/" )
849876 path = root / fname
850877
851- assert _check_path_matches_patterns (
878+ assert bool ( _check_path_matches_patterns (
852879 path ,
853880 ["code" ],
854881 root = None ,
855- ) is (fname == "code" )
882+ )) is (fname == "code" )
856883
857884 assert _check_path_matches_patterns (
858885 path ,
0 commit comments