forked from nest/nestml
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
14 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,18 +22,20 @@ | |
from typing import Sequence, Union, Optional, Mapping, Any, Dict | ||
|
||
from pynestml.codegeneration.code_generator import CodeGenerator | ||
from pynestml.codegeneration.code_generator_utils import CodeGeneratorUtils | ||
from pynestml.frontend.frontend_configuration import FrontendConfiguration | ||
from pynestml.meta_model.ast_neuron import ASTNeuron | ||
from pynestml.meta_model.ast_synapse import ASTSynapse | ||
from pynestml.meta_model.ast_model import ASTModel | ||
|
||
|
||
class NESTDesktopCodeGenerator(CodeGenerator): | ||
""" | ||
Code generator for NEST Desktop | ||
""" | ||
_default_options = { | ||
"neuron_models": [], | ||
"synapse_models": [], | ||
"templates": { | ||
"path": "", | ||
"path": "resources_nest_desktop", | ||
"model_templates": { | ||
"neuron": ["@[email protected]"], | ||
} | ||
|
@@ -45,19 +47,17 @@ def __init__(self, options: Optional[Mapping[str, Any]] = None): | |
super().__init__(self._target, options) | ||
self.setup_template_env() | ||
|
||
def generate_code(self, models: Sequence[Union[ASTNeuron, ASTSynapse]]) -> None: | ||
def generate_code(self, models: Sequence[ASTModel]) -> None: | ||
""" | ||
Generate the .json files for the given neuron and synapse models | ||
:param models: list of neuron models | ||
""" | ||
if not os.path.isdir(FrontendConfiguration.get_target_path()): | ||
os.makedirs(FrontendConfiguration.get_target_path()) | ||
neurons = [model for model in models if isinstance(model, ASTNeuron)] | ||
synapses = [model for model in models if isinstance(model, ASTSynapse)] | ||
neurons, synapses = CodeGeneratorUtils.get_model_types_from_names(models, neuron_models=self.get_option("neuron_models"), | ||
synapse_models=self.get_option("synapse_models")) | ||
self.generate_neurons(neurons) | ||
self.generate_synapses(synapses) | ||
|
||
def _get_neuron_model_namespace(self, neuron: ASTNeuron) -> Dict: | ||
def _get_neuron_model_namespace(self, neuron: ASTModel) -> Dict: | ||
""" | ||
Returns a standard namespace with often required functionality. | ||
:param neuron: a single neuron instance | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters