Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move templates raise_helper() to base class #811

Merged
merged 2 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions pynestml/codegeneration/code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@

from __future__ import annotations

import glob
from abc import abstractmethod

from typing import Any, Dict, Mapping, List, Optional, Sequence, Union

import glob
import os

from jinja2 import Template, Environment, FileSystemLoader
from abc import abstractmethod

from jinja2 import Environment, FileSystemLoader, Template, TemplateRuntimeError

from pynestml.exceptions.invalid_path_exception import InvalidPathException
from pynestml.exceptions.invalid_target_exception import InvalidTargetException
Expand Down Expand Up @@ -59,6 +59,9 @@ def __init__(self, target, options: Optional[Mapping[str, Any]] = None):
self._target = target
super(CodeGenerator, self).__init__(options)

def raise_helper(self, msg):
raise TemplateRuntimeError(msg)

def setup_template_env(self):
"""
Setup the Jinja2 template environment
Expand Down
7 changes: 1 addition & 6 deletions pynestml/codegeneration/nest_code_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@

import datetime

from jinja2 import TemplateRuntimeError

import odetoolbox

import pynestml

from pynestml.cocos.co_co_nest_delay_decorator_specified import CoCoNESTDelayDecoratorSpecified
from pynestml.codegeneration.code_generator import CodeGenerator
from pynestml.codegeneration.nest_assignments_helper import NestAssignmentsHelper
Expand Down Expand Up @@ -155,9 +153,6 @@ def __init__(self, options: Optional[Mapping[str, Any]] = None):

self._ode_toolbox_printer = UnitlessExpressionPrinter(ODEToolboxReferenceConverter())

def raise_helper(self, msg):
raise TemplateRuntimeError(msg)

def set_options(self, options: Mapping[str, Any]) -> Mapping[str, Any]:
# insist on using the old Archiving_Node class for NEST 2
if self.get_option("nest_version").startswith("v2"):
Expand Down