Beispiel #1
0
def gs2dgms_parallel(n_jobs=1, **kwargs):
    """ a wraaper of g2dgm for parallel computation
        sync with the same-named function in fil.py
        put here for parallelizaiton reason
    """

    if dgms_dir_test(
            **kwargs
    )[1]:  #and kwargs.get('ntda', None)!=True: # load only when ntda=False
        dgms = load_dgms(**kwargs)
        return dgms
    try:
        assert 'gs' in globals().keys()
    except AssertionError:
        print(globals().keys())

    try:
        # print('in gs2dgms_parallel', kwargs)
        dgms = Parallel(n_jobs=n_jobs)(delayed(g2dgm)(i, gs[i], **kwargs)
                                       for i in range(len(gs)))
    except NameError:  # name gs is not defined
        sys.exit('NameError and exit')

    save_dgms(dgms, **kwargs)
    return dgms
Beispiel #2
0
def gs2dgms_parallel(n_jobs=1, **kwargs):
    """ a wraaper of g2dgm for parallel computation """

    if dgms_dir_test(**kwargs)[1]:
        dgms = load_dgms(**kwargs)
        return dgms
    try:
        assert 'gs' in globals().keys()
    except AssertionError:
        print(globals().keys())
    dgms = Parallel(n_jobs=n_jobs)(delayed(g2dgm)(i, gs[i], **kwargs)
                                   for i in range(len(gs)))
    save_dgms(dgms, **kwargs)
    return dgms
Beispiel #3
0
def _gs2dgms_parallel(n_jobs=1, **kwargs):
    """ a wraaper of g2dgm for parallel computation """
    if dgms_dir_test(**kwargs)[1]:
        dgms = load_dgms(**kwargs)
        return dgms
    try:
        assert 'gs' in globals().keys()
    except AssertionError:
        print(globals().keys())

    try:
        dgms = Parallel(n_jobs=n_jobs, backend='multiprocessing')(
            delayed(g2dgm)(i, gs[i], **kwargs) for i in range(len(gs)))
    except NameError:  # name gs is not defined
        print('NameError and exit')
        sys.exit()

    save_dgms(dgms, **kwargs)
    return dgms