From 51f48ffb529044198346dd9d35da2ae849e87849 Mon Sep 17 00:00:00 2001 From: "Taewon D. Kim" Date: Wed, 3 Apr 2019 16:28:03 -0400 Subject: [PATCH] Fix flake8 complaints What: 1. Add exception for E203 whitespace before ':' 2. Ignore use of bad variable name "l" 3. Remove unused import Why: 1. There seems to be a discrepancy between the use of ':' within a slice: https://github.com/PyCQA/pycodestyle/issues/373. Since black can handle the whitespace regarding ':' for both in and out of slices, we ignore this error and trust black to format it. 2. Because l is comonly used in equations for density matrices --- tests/test_ham_unrestricted_base.py | 2 +- tests/test_solver_equation.py | 2 +- tox.ini | 2 ++ wfns/ham/density.py | 2 +- wfns/ham/unrestricted_chemical.py | 1 - 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test_ham_unrestricted_base.py b/tests/test_ham_unrestricted_base.py index 4e3b1564..49bcd8bd 100644 --- a/tests/test_ham_unrestricted_base.py +++ b/tests/test_ham_unrestricted_base.py @@ -114,7 +114,7 @@ def test_orb_rotate_jacobi(): theta = 2 * np.pi * (np.random.random() - 0.5) - Test = disable_abstract(BaseUnrestrictedHamiltonian) + Test = disable_abstract(BaseUnrestrictedHamiltonian) # noqa: N806 ham = Test([one_int_alpha, one_int_beta], [two_int_aaaa, two_int_abab, two_int_bbbb]) with pytest.raises(TypeError): diff --git a/tests/test_solver_equation.py b/tests/test_solver_equation.py index e6e25e12..9ab5d84c 100644 --- a/tests/test_solver_equation.py +++ b/tests/test_solver_equation.py @@ -51,7 +51,7 @@ def template_params(self): def check_cma(): """Check if cma module is available.""" try: - import cma + import cma # noqa: F401 except ModuleNotFoundError: return False else: diff --git a/tox.ini b/tox.ini index 2ee26262..1a447b38 100644 --- a/tox.ini +++ b/tox.ini @@ -123,6 +123,8 @@ ignore = W503, # W504 : Line break occurred after a binary operator W504, + # E203 : Whitespace before ':' + E203, # pylintrc [FORMAT] diff --git a/wfns/ham/density.py b/wfns/ham/density.py index df47eacd..3dd3dc85 100644 --- a/wfns/ham/density.py +++ b/wfns/ham/density.py @@ -335,7 +335,7 @@ def density_matrix( # if double excitation elif len(left_diff) == 2: i, j = left_diff - k, l = right_diff + k, l = right_diff # noqa: E741 add_two_density(two_densities, i, j, k, l, val, orbtype=orbtype) add_two_density(two_densities, j, i, l, k, val, orbtype=orbtype) add_two_density(two_densities, k, l, i, j, val, orbtype=orbtype) diff --git a/wfns/ham/unrestricted_chemical.py b/wfns/ham/unrestricted_chemical.py index 3f8c59b8..6f6d9ff0 100644 --- a/wfns/ham/unrestricted_chemical.py +++ b/wfns/ham/unrestricted_chemical.py @@ -2,7 +2,6 @@ import numpy as np from wfns.backend import slater, math_tools from wfns.ham.unrestricted_base import BaseUnrestrictedHamiltonian -from wfns.ham.generalized_chemical import GeneralizedChemicalHamiltonian class UnrestrictedChemicalHamiltonian(BaseUnrestrictedHamiltonian):