diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a458e52d99a099f588afec1fe160231b1eb79f4d..1faa51730acc94138268cd09cd3acd39e7e73504 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -53,6 +53,17 @@ Documentation: only: - master +Pylint: + script: + - export PY_EXE=python3 + - EXTRA_INSTALL="numpy" + - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-pylint.sh + - ". ./prepare-and-run-pylint.sh dagrt test/test_*.py" + tags: + - python3 + except: + - tags + Flake8: script: - curl -L -O -k https://gitlab.tiker.net/inducer/ci-support/raw/master/prepare-and-run-flake8.sh diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 329408a30efc45438275dc48b36d0af12e6d3b41..f95338d6e6156dba2732151fcdcc7adeb3004767 100644 --- a/dagrt/codegen/fortran.py +++ b/dagrt/codegen/fortran.py @@ -291,6 +291,9 @@ class UserTypeReferenceTransformer(IdentityMapper): else: raise TypeError("unsupported object") + def transform(self, expr): + raise NotImplementedError + def map_variable(self, expr): if isinstance(self.find_sym_kind(expr), UserType): return self.transform(expr) @@ -1004,9 +1007,6 @@ class CodeGenerator(StructuredCodeGenerator): def expr(self, expr): return self.expr_mapper(expr) - def rhs(self, rhs): - return self.name_manager.name_rhs(rhs) - def emit(self, line): self.emitter(line) @@ -2050,7 +2050,7 @@ class CodeGenerator(StructuredCodeGenerator): self.emitter.__exit__(None, None, None) def emit_else_begin(self): - self.emitter.emit_else() + self.emitter.emit_else() # pylint:disable=no-member def emit_assign_expr(self, assignee_sym, assignee_subscript, expr): from dagrt.codegen.data import UserType, Array diff --git a/dagrt/codegen/transform.py b/dagrt/codegen/transform.py index ef8dcca5fba4a2313c98280cfc1e598b024f73b7..a1786e17206cc8c5ecaa7892890e8d14002e9ed9 100644 --- a/dagrt/codegen/transform.py +++ b/dagrt/codegen/transform.py @@ -89,7 +89,7 @@ def eliminate_self_dependencies(dag): class FunctionArgumentIsolator(IdentityMapper): def __init__(self, new_statements, stmt_id_gen, var_name_gen): - super(IdentityMapper, self).__init__() + super(FunctionArgumentIsolator, self).__init__() self.new_statements = new_statements self.stmt_id_gen = stmt_id_gen self.var_name_gen = var_name_gen @@ -175,7 +175,7 @@ def isolate_function_arguments(dag): class FunctionCallIsolator(IdentityMapper): def __init__(self, new_statements, stmt_id_gen, var_name_gen): - super(IdentityMapper, self).__init__() + super(FunctionCallIsolator, self).__init__() self.new_statements = new_statements self.stmt_id_gen = stmt_id_gen self.var_name_gen = var_name_gen diff --git a/dagrt/expression.py b/dagrt/expression.py index 24b97ccde650ac2d1ef65bd59da65de748ca2f4f..f27f0a905cb9a0d824abb46c103e7ed4e91179e7 100644 --- a/dagrt/expression.py +++ b/dagrt/expression.py @@ -190,7 +190,7 @@ class _ExpressionCollapsingMapper(IdentityMapper): if len(non_constants) > 1: return combine_func(non_constants) else: - return self.non_constants[0] + return non_constants[0] if len(constants) == 1 and _is_atomic(constants[0]): folded_constant = constants[0] diff --git a/dagrt/language.py b/dagrt/language.py index 1167bf371f0b663c40fd82c4dad0aebb1986cfe5..9e5fb1685b936f6a7479315f5c9e4c15848b31a1 100644 --- a/dagrt/language.py +++ b/dagrt/language.py @@ -644,12 +644,12 @@ class DAGCode(RecordWithoutPickling): """ .. attribute:: phases - is a map from time integrator state names to :class:`ExecutionPhase` + is a map from time integrator phase names to :class:`ExecutionPhase` instances .. attribute:: initial_phase - the name of the starting state + the name of the starting phase """ @classmethod @@ -823,6 +823,11 @@ class CodeBuilder(object): .. automethod:: if_ .. automethod:: else_ .. automethod:: __call__ + + .. method:: assign + + Alias for :func:`CodeBuilder.__call__`. + .. automethod:: fresh_var_name .. automethod:: fresh_var .. automethod:: assign_implicit diff --git a/dagrt/transform.py b/dagrt/transform.py index 2d656c3cf20860e62c2e515967105ca5cb0ff729..95c0a290a92bc11e2ffad87947a7f2152bf90552 100644 --- a/dagrt/transform.py +++ b/dagrt/transform.py @@ -23,26 +23,6 @@ THE SOFTWARE. """ -# {{{ insert_empty_intermediate_state - -def insert_empty_intermediate_state(dag, phase_name, after_phase): - new_phases = dag.phases.copy() - - if phase_name in new_phases: - raise ValueError("phase '%s' already exists" - % phase_name) - - from dagrt.language import DAGCode, ExecutionPhase - new_phases[phase_name] = ExecutionPhase( - next_phase=new_phases[after_phase].next_phase) - new_phases[after_phase] = new_phases[after_phase].copy( - next_phase=phase_name) - - return DAGCode(dag.statements, new_phases, dag.initial_phase) - -# }}} - - # {{{ fuse_two_phases def fuse_two_phases(phase_name, phase1, phase2): diff --git a/doc/index.rst b/doc/index.rst index dbaa3a28b1d9cc9c0f43e008fc00e907d33514ea..10c4fd2a9cdc6baa4dd4099b0c1059defecee2cb 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,5 +1,5 @@ Welcome to dagrt's documentation! -================================ +================================= TODO: Insert example here. diff --git a/test/test_codegen_python.py b/test/test_codegen_python.py index 5df414f0d12ce3d38e5ff043900a78dfbc9feee6..237c736632c0a778ca8241ff127b0c22651a4cf1 100755 --- a/test/test_codegen_python.py +++ b/test/test_codegen_python.py @@ -162,8 +162,10 @@ def test_basic_raise_codegen(): assert False except method.TimeStepUnderflow: pass + except Method.StepError as e: + assert e.condition == "TimeStepUnderflow" except Exception as e: - assert isinstance(e, Method.StepError) and e.condition == "TimeStepUnderflow" + assert False, e def test_basic_fail_step_codegen():