Esempio n. 1
0
def test_argnames_order(crumb):
    base_dir = BASE_DIR
    crumb2 = crumb.replace(base_dir=base_dir)

    assert sorted(list(_depth_names(crumb.path))) == list(_depth_names(crumb.path))
    assert sorted(list(_depth_names(crumb2.path))) == list(_depth_names(crumb2.path))

    assert [arg_name for depth, arg_name in sorted(list(_depth_names(crumb2.path)))] == list(_arg_names(crumb2.path))
Esempio n. 2
0
def test_argnames_order(crumb):
    base_dir = BASE_DIR
    crumb2 = crumb.replace(base_dir=base_dir)

    assert sorted(list(_depth_names(crumb .path))) == list(_depth_names(crumb .path))
    assert sorted(list(_depth_names(crumb2.path))) == list(_depth_names(crumb2.path))

    assert [arg_name for depth, arg_name in sorted(list(_depth_names(crumb2.path)))] == list(_arg_names(crumb2.path))
Esempio n. 3
0
def test_rem_deps(crumb):
    values = {arg: dpth for dpth, arg in _depth_names(crumb.path)}
    assert not crumb._args_open_parents(values)

    del values['base_dir']
    assert crumb._args_open_parents(values) == ['base_dir']

    del values['subject_id']
    assert crumb._args_open_parents(values) == ['base_dir', 'subject_id']

    values = {arg: dpth for dpth, arg in _depth_names(crumb.path)}
    del values['base_dir']
    del values['modality']
    assert crumb._args_open_parents(values) == ['base_dir', 'modality']

    values = {arg: dpth for dpth, arg in _depth_names(crumb.path)}
    del values['image']
    del values['modality']
    assert not crumb._args_open_parents(values)
Esempio n. 4
0
def test_rem_deps(crumb):

    values = {arg: dpth for dpth, arg in _depth_names(crumb.path)}
    assert not crumb._args_open_parents(values)

    del values['base_dir']
    assert crumb._args_open_parents(values) == ['base_dir']

    del values['subject_id']
    assert crumb._args_open_parents(values) == ['base_dir', 'subject_id']

    values = {arg: dpth for dpth, arg in _depth_names(crumb.path)}
    del values['base_dir']
    del values['modality']
    assert crumb._args_open_parents(values) == ['base_dir', 'modality']

    values = {arg: dpth for dpth, arg in _depth_names(crumb.path)}
    del values['image']
    del values['modality']
    assert not crumb._args_open_parents(values)
Esempio n. 5
0
def test_contains(tmp_crumb):
    assert 'modality' in tmp_crumb
    assert 'subject_id' in tmp_crumb
    assert 'image' in tmp_crumb
    assert 'raw' not in tmp_crumb

    tmp_crumb['image'] = 'image'

    assert 'image' in tmp_crumb.all_args()
    assert 'image' not in dict(_depth_names(tmp_crumb.path))
    assert 'image' not in tmp_crumb.open_args()
    assert tmp_crumb.has_set('image')
Esempio n. 6
0
def test_contains(tmp_crumb):
    assert 'modality'   in tmp_crumb
    assert 'subject_id' in tmp_crumb
    assert 'image'      in tmp_crumb
    assert 'raw'    not in tmp_crumb

    tmp_crumb['image'] = 'image'

    assert 'image' in tmp_crumb.all_args()
    assert 'image' not in dict(_depth_names(tmp_crumb.path))
    assert 'image' not in tmp_crumb.open_args()
    assert tmp_crumb.has_set('image')
Esempio n. 7
0
    def _open_arg_items(self):
        """ Return an iterator to the crumb _argidx items in `self` that have
        not been replaced yet. In the same order as they appear in the crumb path.

        Returns
        -------
        depth_args: generator of 2-tuple of int and str
            For each item will return the depth index of the undefined crumb
            argument and its name.

        Note
        ----
        I know that there is shorter/faster ways to program this but I wanted to maintain the
        order of the arguments in argidx in the result of this function.
        """
        for depth, arg_name in _depth_names(self.path):
            yield depth, arg_name