INNER CODE UNIT · Python

load_algorithm_functions

nachifur/MulimgViewer · src/mulimgviewer/src/custom_func/main.py:28

def load_algorithm_functions(algorithm_type):
    available_algorithms = get_available_algorithms()
    if not available_algorithms:
        return load_default_functions()
    if algorithm_type < 0 or algorithm_type >= len(available_algorithms):
        algorithm_type = 0
    algorithm_name = available_algorithms[algorithm_type]
    algorithm_path = Path(__file__).parent / algorithm_name / "main.py"
    if not algorithm_path.exists():
        return load_default_functions()
    try:
        namespace = {}
        with open(algorithm_path, 'r', encoding='utf-8') as f:
            code = f.read()
        exec(code, namespace)
        return namespace
    except:
        return load_default_functions()

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…