Skip to content

Model Functions

compile_in_folder(folder_name, net=None, clean=False, silent=False) #

Creates the compilation folder in annarchy_folders/ or uses existing ones. Compiles the current network.

Parameters:

Name Type Description Default
folder_name str

Name of the folder within annarchy_folders/

required
net ANNarchy network

ANNarchy network. Default: None.

None
clean bool

If True, the library is recompiled entirely, else only the changes since last compilation are compiled. Default: False.

False
silent bool

Suppress output. Defaults to False.

False
Source code in src/CompNeuroPy/model_functions.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def compile_in_folder(folder_name, net=None, clean=False, silent=False):
    """
    Creates the compilation folder in annarchy_folders/ or uses existing ones. Compiles
    the current network.

    Args:
        folder_name (str):
            Name of the folder within annarchy_folders/
        net (ANNarchy network, optional):
            ANNarchy network. Default: None.
        clean (bool, optional):
            If True, the library is recompiled entirely, else only the changes since
            last compilation are compiled. Default: False.
        silent (bool, optional):
            Suppress output. Defaults to False.
    """
    sf.create_dir("annarchy_folders/" + folder_name, print_info=False)
    if isinstance(net, type(None)):
        compile("annarchy_folders/" + folder_name, clean=clean, silent=silent)
    else:
        net.compile("annarchy_folders/" + folder_name, clean=clean, silent=silent)
    if os.getcwd().split("/")[-1] == "annarchy_folders":
        os.chdir("../")

annarchy_compiled(net_id=0) #

Check if ANNarchy network was compiled.

Parameters:

Name Type Description Default
net_id int

Network ID. Default: 0.

0
Source code in src/CompNeuroPy/model_functions.py
38
39
40
41
42
43
44
45
46
def annarchy_compiled(net_id=0):
    """
    Check if ANNarchy network was compiled.

    Args:
        net_id (int, optional):
            Network ID. Default: 0.
    """
    return Global._network[net_id]["compiled"]

get_full_model() #

Return all current population and projection names.

Returns:

Name Type Description
model_dict dict

Dictionary with keys "populations" and "projections" and values lists of population and projection names, respectively.

Source code in src/CompNeuroPy/model_functions.py
49
50
51
52
53
54
55
56
57
58
59
60
61
def get_full_model():
    """
    Return all current population and projection names.

    Returns:
        model_dict (dict):
            Dictionary with keys "populations" and "projections" and values lists of
            population and projection names, respectively.
    """
    return {
        "populations": [pop.name for pop in populations()],
        "projections": [proj.name for proj in projections()],
    }

cnp_clear(functions=True, neurons=True, synapses=True, constants=True) #

Like clear with ANNarchy, but CompNeuroModel objects are also cleared.

Parameters:

Name Type Description Default
functions bool

If True, all functions are cleared. Default: True.

True
neurons bool

If True, all neurons are cleared. Default: True.

True
synapses bool

If True, all synapses are cleared. Default: True.

True
constants bool

If True, all constants are cleared. Default: True.

True
Source code in src/CompNeuroPy/model_functions.py
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
def cnp_clear(functions=True, neurons=True, synapses=True, constants=True):
    """
    Like clear with ANNarchy, but CompNeuroModel objects are also cleared.

    Args:
        functions (bool, optional):
            If True, all functions are cleared. Default: True.
        neurons (bool, optional):
            If True, all neurons are cleared. Default: True.
        synapses (bool, optional):
            If True, all synapses are cleared. Default: True.
        constants (bool, optional):
            If True, all constants are cleared. Default: True.
    """
    clear(functions=functions, neurons=neurons, synapses=synapses, constants=constants)
    for model_name in CompNeuroModel._initialized_models.keys():
        CompNeuroModel._initialized_models[model_name] = False
    for model_name in CompNeuroModel._compiled_models.keys():
        CompNeuroModel._compiled_models[model_name] = False