diff --git a/.flake8 b/.flake8 deleted file mode 100644 index 4ec3f4456ed1bbdb63b6b71a550099ab6d4e61d0..0000000000000000000000000000000000000000 --- 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 0cdb6cf89c9e7af69b6eb2fd687bfa7fb2be16f9..e67fb8150ad277906cf8c6a47fa3aacb5ebb4cb7 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 548783137f5512d03cd10bf8606bd52a52fcc700..cef06d8db4b7fb9aa16d72353266348e36b1e82f 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 bc139b97fe2c981d40fe4800ff6a85e83f912019..752dd6af62aff1168f9667e2e655e8d5decbb0d9 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 581d5d64948d529198c239832eb0e52066f78cbf..393e038a9cf5ee343db15399f2a0c227247a78d7 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 8c5c1e1c77e149cc8c56d0eb7e6415f53989e49d..c964f65d0ecd9233a978bd34a80762bb46acb546 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 8a4e55b949b7e2014995b97c3be83dee2f5cffa4..e6c8623c8d740c0c87a8523213675aef849cf7fd 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)