From 6cf58dcf5c136497b4eda669c7096848842b2bd4 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:06:45 -0500 Subject: [PATCH 1/7] Doc fixes --- dagrt/language.py | 5 +++++ doc/index.rst | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dagrt/language.py b/dagrt/language.py index 1167bf3..9907e9d 100644 --- a/dagrt/language.py +++ b/dagrt/language.py @@ -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/doc/index.rst b/doc/index.rst index dbaa3a2..10c4fd2 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -1,5 +1,5 @@ Welcome to dagrt's documentation! -================================ +================================= TODO: Insert example here. -- GitLab From 7e5bac3c1eeac597cc2933f9812fa7e35a6d2dc8 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:22:01 -0500 Subject: [PATCH 2/7] More doc fixes --- dagrt/language.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dagrt/language.py b/dagrt/language.py index 9907e9d..9e5fb16 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 -- GitLab From b7774cf124fe7eb1fa8b3a3a2f4d41fd4fdd84c0 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:22:11 -0500 Subject: [PATCH 3/7] Add pylint job --- .gitlab-ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a458e52..ecd1f99 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 pylint 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 -- GitLab From a70e669a1c0df75c99c97fbf3ca63b4a578db8e8 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:22:25 -0500 Subject: [PATCH 4/7] Fortran fixes --- dagrt/codegen/fortran.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dagrt/codegen/fortran.py b/dagrt/codegen/fortran.py index 329408a..f95338d 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 -- GitLab From a64da3988352d71a9feb56ab4a181787e948fc1d Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:22:49 -0500 Subject: [PATCH 5/7] Delete dead, broken function --- dagrt/transform.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/dagrt/transform.py b/dagrt/transform.py index 2d656c3..95c0a29 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): -- GitLab From e9abfa514564a873b21c7cec588589997a48c5e7 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:23:12 -0500 Subject: [PATCH 6/7] Misc fixes --- dagrt/codegen/transform.py | 4 ++-- dagrt/expression.py | 2 +- test/test_codegen_python.py | 4 +++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dagrt/codegen/transform.py b/dagrt/codegen/transform.py index ef8dcca..a1786e1 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 24b97cc..f27f0a9 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/test/test_codegen_python.py b/test/test_codegen_python.py index 5df414f..237c736 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(): -- GitLab From dbf1aa7f5283e5548b8bc6dc315abc5aecd7dc26 Mon Sep 17 00:00:00 2001 From: Matt Wala Date: Tue, 16 Apr 2019 15:24:02 -0500 Subject: [PATCH 7/7] Fix pylint job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ecd1f99..1faa517 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -58,7 +58,7 @@ Pylint: - 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 pylint test/test_*.py" + - ". ./prepare-and-run-pylint.sh dagrt test/test_*.py" tags: - python3 except: -- GitLab