示例#1
0
    def test_iaf_cond_alpha_functional(self):
        path = str(
            os.path.realpath(
                os.path.join(
                    os.path.dirname(__file__),
                    os.path.join('..', 'models', 'iaf_cond_alpha.nestml'))))

        params = list()
        params.append('-path')
        params.append(path)
        # params.append('-dry')
        params.append('-logging_level')
        params.append('NO')
        params.append('-target')
        params.append('target')
        params.append('-dev')

        FrontendConfiguration.config(params)

        compilation_unit = ModelParser.parse_model(path)

        iaf_cond_alpha_functional = list()
        iaf_cond_alpha_functional.append(compilation_unit.get_neuron_list()[0])
        generate_nest_module_code(iaf_cond_alpha_functional)
        analyse_and_generate_neurons(iaf_cond_alpha_functional)
示例#2
0
def main(args):
    try:
        FrontendConfiguration.config(args)
    except InvalidPathException:
        print('Not a valid path to model or directory: "%s"!' %
              FrontendConfiguration.get_path())
        return
    # init log dir
    create_report_dir()
    # The handed over parameters seem to be correct, proceed with the main routine
    init_predefined()
    # now proceed to parse all models
    compilation_units = list()
    for file in FrontendConfiguration.get_files():
        parsed_unit = ModelParser.parse_model(file)
        if parsed_unit is not None:
            compilation_units.append(parsed_unit)
    # generate a list of all neurons
    neurons = list()
    for compilationUnit in compilation_units:
        neurons.extend(compilationUnit.get_neuron_list())
    # check if across two files two neurons with same name have been defined
    CoCosManager.check_not_two_neurons_across_units(compilation_units)
    # now exclude those which are broken, i.e. have errors.
    if not FrontendConfiguration.is_dev():
        for neuron in neurons:
            if Logger.has_errors(neuron):
                code, message = Messages.get_neuron_contains_errors(
                    neuron.get_name())
                Logger.log_message(neuron=neuron,
                                   code=code,
                                   message=message,
                                   error_position=neuron.get_source_position(),
                                   log_level=LoggingLevel.INFO)
                neurons.remove(neuron)
    if not FrontendConfiguration.is_dry_run():
        analyse_and_generate_neurons(neurons)
        generate_nest_module_code(neurons)
    else:
        code, message = Messages.get_dry_run()
        Logger.log_message(neuron=None,
                           code=code,
                           message=message,
                           log_level=LoggingLevel.INFO)
    if FrontendConfiguration.store_log:
        store_log_to_file()
    return