From bfc247604d73ce08b46f8d60702f288ebcc5885a Mon Sep 17 00:00:00 2001 From: Stephan Seitz <stephan.seitz@fau.de> Date: Wed, 7 Aug 2019 19:35:48 +0200 Subject: [PATCH] Lint and .gitlab-ci.yml --- .flake8 | 3 --- .gitlab-ci.yml | 9 ++++----- setup.cfg | 4 +++- src/pystencils_autodiff/__init__.py | 4 ++-- src/pystencils_autodiff/_layout_fixer.py | 5 +++-- src/pystencils_autodiff/adjoint_field.py | 2 +- src/pystencils_autodiff/autodiff.py | 5 +++-- 7 files changed, 16 insertions(+), 16 deletions(-) delete mode 100644 .flake8 diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 4ec3f44..0000000 --- a/.flake8 +++ /dev/null @@ -1,3 +0,0 @@ -[flake8] -max-line-length=120 -ignore = W293 W503 W291 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0cdb6cf..e67fb81 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -13,8 +13,7 @@ minimal-windows: - conda env list - python -c "import numpy" - pip install -e . - - pip install pytest - - pytest + - python3 setup.py test minimal-ubuntu: stage: test @@ -23,7 +22,8 @@ minimal-ubuntu: - $ENABLE_NIGHTLY_BUILDS image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_ubuntu script: - - pytest + - pip install -e . + - python3 setup.py test tags: - docker @@ -35,8 +35,7 @@ minimal-conda: image: i10git.cs.fau.de:5005/pycodegen/pycodegen/minimal_conda script: - pip install -e . - - pip install pytest - - pytest + - python3 setup.py test tags: - docker diff --git a/setup.cfg b/setup.cfg index 5487831..cef06d8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -30,7 +30,7 @@ package_dir = # DON'T CHANGE THE FOLLOWING LINE! IT WILL BE UPDATED BY PYSCAFFOLD! setup_requires = pyscaffold>=3.2a0,<3.3a0 # Add here dependencies of your project (semicolon/line-separated), e.g. -install_requires = numpy;pystencils;jinja2 +install_requires = numpy;pystencils>=0.2.6;jinja2 # The usage of test_requires is discouraged, see `Dependency Management` docs tests_require = pytest;pytest-cov;tensorflow;torch # Require a specific Python version, e.g. Python 2.7 or >= 3.4 @@ -110,6 +110,8 @@ exclude = dist .eggs docs/conf.py +max-line-length=120 +ignore = W293 W503 W291 W504 [pyscaffold] # PyScaffold's parameters when the project was created. diff --git a/src/pystencils_autodiff/__init__.py b/src/pystencils_autodiff/__init__.py index bc139b9..752dd6a 100644 --- a/src/pystencils_autodiff/__init__.py +++ b/src/pystencils_autodiff/__init__.py @@ -1,5 +1,5 @@ -import pystencils_autodiff.backends -from pystencils_autodiff._field_to_tensors import ( +import pystencils_autodiff.backends # NOQA +from pystencils_autodiff._field_to_tensors import ( # NOQA tf_constant_from_field, tf_placeholder_from_field, tf_scalar_variable_from_field, tf_variable_from_field, torch_tensor_from_field) from pystencils_autodiff.adjoint_field import AdjointField diff --git a/src/pystencils_autodiff/_layout_fixer.py b/src/pystencils_autodiff/_layout_fixer.py index 581d5d6..393e038 100644 --- a/src/pystencils_autodiff/_layout_fixer.py +++ b/src/pystencils_autodiff/_layout_fixer.py @@ -1,5 +1,4 @@ import numpy as np -import pystencils as ps from pystencils_autodiff.backends import AVAILABLE_BACKENDS @@ -10,7 +9,9 @@ def fix_layout(array, target_field, backend): # Just index coordinate wrong? swapped_array = np.swapaxes(array, 0, -1) - if swapped_array.strides == target_field.strides and swapped_array.shape == target_field.shade and target_field.index_dimensions == 1: + if (swapped_array.strides == target_field.strides and + swapped_array.shape == target_field.shade and + target_field.index_dimensions == 1): array = swapped_array # Everything ok diff --git a/src/pystencils_autodiff/adjoint_field.py b/src/pystencils_autodiff/adjoint_field.py index 8c5c1e1..c964f65 100644 --- a/src/pystencils_autodiff/adjoint_field.py +++ b/src/pystencils_autodiff/adjoint_field.py @@ -12,7 +12,7 @@ class AdjointField(pystencils.Field): def __init__(self, forward_field, name_prefix='diff'): new_name = name_prefix + forward_field.name super().__init__(new_name, forward_field.field_type, forward_field._dtype, - forward_field._layout, forward_field.shape, forward_field.strides) + forward_field._layout, forward_field.shape, forward_field.strides) self.corresponding_forward_field = forward_field self.name_prefix = name_prefix diff --git a/src/pystencils_autodiff/autodiff.py b/src/pystencils_autodiff/autodiff.py index 8a4e55b..e6c8623 100644 --- a/src/pystencils_autodiff/autodiff.py +++ b/src/pystencils_autodiff/autodiff.py @@ -281,7 +281,8 @@ Backward: if forward_read_field in self._time_constant_fields: # Accumulate in case of time_constant_fields assignment = ps.Assignment( - diff_read_field.center_vector[index], diff_read_field.center_vector[index] + diff_read_field_sum[index]) + diff_read_field.center_vector[index], + diff_read_field.center_vector[index] + diff_read_field_sum[index]) else: # If time dependent, we just need to assign the sum for the current time step assignment = ps.Assignment( @@ -302,7 +303,7 @@ Backward: if self._do_common_subexpression_elimination: backward_assignments = ps.simp.sympy_cse_on_assignment_list( backward_assignments) - except: + except Exception: pass # print("Common subexpression elimination failed") # print(err) -- GitLab