How to use the configargparse.Namespace function in ConfigArgParse

To help you get started, we’ve selected a few ConfigArgParse examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_with_files(self, application_parse):
        assert is_recursive_subnamespace(Namespace(application=Namespace(files=["img_1.mnc"]),
                                                   mbm=Namespace(lsq12=Namespace(max_pairs=20))),
                                         application_parse)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_with_files(self, application_parse):
        assert is_recursive_subnamespace(Namespace(application=Namespace(files=["img_1.mnc"]),
                                                   mbm=Namespace(lsq12=Namespace(max_pairs=20))),
                                         application_parse)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_deeper_nesting(self, four_mbm_parse):
        assert is_recursive_subnamespace(Namespace(first_two=Namespace(mbm1=Namespace(lsq12=Namespace(max_pairs=22)),
                                                                       mbm2=Namespace(lsq12=Namespace(max_pairs=23))),
                                                   last_two=Namespace(mbm1=Namespace(lsq12=Namespace(max_pairs=24)),
                                                                      mbm2=Namespace(lsq12=Namespace(max_pairs=25)))),
                                         four_mbm_parse)
    def test_with_files(self, application_parse):
github SkygearIO / py-skygear / skygear / asset / test_cloud.py View on Github external
def mock_options(self, public=False):
        return Namespace(
            appname='skygear-test',
            cloud_asset_host='http://mock-cloud-asset.dev',
            cloud_asset_token='mock-cloud-asset-token',
            cloud_asset_public_prefix='http://mock-cloud-asset.dev/public',
            cloud_asset_private_prefix='http://mock-cloud-asset.dev/private',
            asset_store_public=public)
github Mouse-Imaging-Centre / pydpiper / test / test_arguments.py View on Github external
def test_nested_parsing(self, two_mbm_parse):
        assert is_recursive_subnamespace(Namespace(mbm1=Namespace(lsq12=Namespace(max_pairs=22)),
                                                   mbm2=Namespace(lsq12=Namespace(max_pairs=25))),
                                         two_mbm_parse)
    def test_deeper_nesting(self, four_mbm_parse):
github SkygearIO / py-skygear / skygear / asset / test_cloud.py View on Github external
def test_sign_public(self):
        signer = CloudAssetSigner.create(Namespace(
            appname='skygear-test',
            cloud_asset_host='http://mock-cloud-asset.dev',
            cloud_asset_token='mock-cloud-asset-token',
            cloud_asset_public_prefix='http://mock-cloud-asset.dev/public',
            cloud_asset_private_prefix='http://mock-cloud-asset.dev/private',
            asset_store_public=True))
        assert signer.sign('a good fixture') == \
            'http://mock-cloud-asset.dev/public/skygear-test/a%20good%20fixture'  # noqa
github Mouse-Imaging-Centre / pydpiper / pydpiper / pipelines / MBM.py View on Github external
output_xfms = output_xfms.assign(xfm_common=xfms_common, overall_xfm_common=overall_xfms_common)

        log_nlin_det_common, log_full_det_common = [dets.map(lambda d:
                                                      s.defer(mincresample_new(
                                                        img=d,
                                                        xfm=xfm_to_common.xfm,
                                                        like=common_space_model,
                                                        postfix="_common",
                                                        extra_flags=("-keep_real_range",),
                                                        interpolation=Interpolation.nearest_neighbour)))
                                                    for dets in (determinants.log_nlin_det, determinants.log_full_det)]

        determinants = determinants.assign(log_nlin_det_common=log_nlin_det_common,
                                           log_full_det_common=log_full_det_common)

    output = Namespace(avg_img=lsq12_nlin_result.avg_img, xfms=output_xfms, determinants=determinants)

    if options.mbm.common_space.do_common_space_registration:
        output.model_common = model_common

    if options.mbm.segmentation.run_maget:
        output.maget_result = maget_result

    return Result(stages=s, output=output)
github Mouse-Imaging-Centre / pydpiper / pydpiper / core / arguments.py View on Github external
fixed = (q.cast(current_ns.__dict__[q.namespace]) #(q.cast(**vars(current_ns.__dict__[q.namespace]))
                                                    if q.cast else current_ns.__dict__[q.namespace])
                if isinstance(fixed, tuple):
                    fixed = fixed.replace(flags_=flags)
                elif isinstance(fixed, Namespace):
                    setattr(fixed, "flags_", flags)
                else:
                    raise ValueError("currently only Namespace and NamedTuple objects are supported return types from "
                                     "parsing; got %s (a %s)" % (fixed, type(fixed)))
                current_ns.__dict__[q.namespace] = fixed
                # TODO current_ns or current_namespace or ns or namespace?
        else:
            raise TypeError("parser %s wasn't a %s (%s or %s) but a %s" %
                            (p, Parser, BaseParser, CompoundParser, p.__class__))

    main_ns = Namespace()
    go_2(parser, current_prefix="", current_ns=main_ns)
    return main_ns
github Mouse-Imaging-Centre / pydpiper / pydpiper / pipelines / twolevel_model_building.py View on Github external
#    maget_options.maget.maget.mask = maget_options.maget.maget.mask_only = False   # already done above
    #    del maget_options.mbm

        # again using a weird combination of vectorized and loop constructs ...
    #    s.defer(maget([xfm.resampled for _ix, m in first_level_results.iterrows()
    #                   for xfm in m.build_model.xfms.rigid_xfm],
    #                  options=maget_options,
    #                  prefix="%s_MAGeT" % options.application.pipeline_name,
    #                  output_dir=os.path.join(options.application.output_directory,
    #                                          options.application.pipeline_name + "_processed")))

    # TODO resampling to database model ...

    # TODO there should be one table containing all determinants (first level, overall, resampled first level) for each file
    # and another containing some groupwise information (averages and transforms to the common average)
    return Result(stages=s, output=Namespace(first_level_results=first_level_results,
                                             resampled_determinants=resampled_determinants,
                                             overall_determinants=overall_determinants))