Skip to content

Commit c1434c9

Browse files
wxmerktnim65s
andauthored
Fix flake8 errors (#318)
* Fix flake8 errors * flake8: ignore E203 * flake8: 119 cols for now * black * fix comment style * exclude cmake.py * clang-format: sort include Co-authored-by: Guilhem Saurel <[email protected]>
1 parent ad7d1fe commit c1434c9

14 files changed

+43
-23
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ repos:
55
rev: v14.0.6
66
hooks:
77
- id: clang-format
8-
args: ['--style={BasedOnStyle: Google, SortIncludes: false}']
8+
args: [--style=Google]
99
- repo: https://github.com/pre-commit/pre-commit-hooks
1010
rev: v4.3.0
1111
hooks:

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ EigenPy — Efficient Python bindings between Numpy/Eigen
77
<a href="https://anaconda.org/conda-forge/eigenpy"><img src="https://img.shields.io/conda/dn/conda-forge/eigenpy.svg" alt="Conda Downloads"/></a>
88
<a href="https://anaconda.org/conda-forge/eigenpy"><img src="https://img.shields.io/conda/vn/conda-forge/eigenpy.svg" alt="Conda Version"/></a>
99
<a href="https://badge.fury.io/py/eigenpy"><img src="https://badge.fury.io/py/eigenpy.svg" alt="PyPI version"></a>
10+
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"></a>
1011
</p>
1112

1213
**EigenPy** is an open source framework which allows to bind the famous [Eigen](http://eigen.tuxfamily.org) C++ library in Python.

benchmarks/bench-switch.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import eigenpy
44
import numpy as np
55

6-
import time
7-
import timeit
6+
import time # noqa
7+
import timeit # noqa
88

99
from IPython import get_ipython
1010

python/eigenpy/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# Copyright (c) 2017-2021 CNRS INRIA
33
#
44

5-
from .eigenpy_pywrap import *
6-
from .eigenpy_pywrap import __version__, __raw_version__
5+
from .eigenpy_pywrap import * # noqa
6+
from .eigenpy_pywrap import __version__, __raw_version__ # noqa

setup.cfg

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
extend-ignore = E203
3+
max-line-length = 88
4+
exclude = cmake/.docs/cmake.py

unittest/eigen_ref.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <iostream>
77

88
#include "eigenpy/eigenpy.hpp"
9+
// include main header first
910
#include "eigenpy/eigen-from-python.hpp"
1011

1112
using namespace Eigen;

unittest/python/test_LLT.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import eigenpy
22

33
import numpy as np
4-
import numpy.linalg as la
54

65
dim = 100
76
A = np.random.rand(dim, dim)

unittest/python/test_complex.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import print_function
22

33
import numpy as np
4-
from complex import *
4+
from complex import switchToNumpyArray, real, imag, ascomplex
55

66
switchToNumpyArray()
77

unittest/python/test_dimensions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import print_function
22

33
import eigenpy
4-
import numpy as np
54

65
quat = eigenpy.Quaternion()
76
# By default, we convert as numpy.matrix

unittest/python/test_eigen_ref.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
import numpy as np
2-
from eigen_ref import *
2+
from eigen_ref import (
3+
printMatrix,
4+
asRef,
5+
asConstRef,
6+
fill,
7+
getBlock,
8+
editBlock,
9+
modify_block,
10+
has_ref_member,
11+
)
312

413

514
def test(mat):

unittest/python/test_geometry.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
from __future__ import print_function
22

3-
from geometry import *
3+
from geometry import (
4+
AngleAxis,
5+
Quaternion,
6+
testOutAngleAxis,
7+
testInAngleAxis,
8+
testOutQuaternion,
9+
testInQuaternion,
10+
)
411
import numpy as np
5-
from numpy import cos, sin
12+
from numpy import cos
613

714
verbose = True
815

unittest/python/test_return_by_ref.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_shared(mat):
2121
try:
2222
m_const_ref.fill(2)
2323
assert False
24-
except:
24+
except Exception:
2525
assert True
2626

2727

@@ -43,7 +43,7 @@ def test_not_shared(mat):
4343
try:
4444
m_const_ref.fill(2)
4545
assert True
46-
except:
46+
except Exception:
4747
assert False
4848

4949

unittest/python/test_self_adjoint_eigen_solver.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import eigenpy
22

3-
eigenpy.switchToNumpyArray()
4-
53
import numpy as np
6-
import numpy.linalg as la
4+
5+
eigenpy.switchToNumpyArray()
76

87
dim = 100
98
A = np.random.rand(dim, dim)

unittest/python/test_user_type.py

+8-7
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ def test(dtype):
1414
assert (mat == mat_copy).all()
1515
assert not (mat != mat_copy).all()
1616

17-
# if version.parse(np.__version__) >= version.parse("1.21.0"): # check if it fixes for new versio of NumPy
18-
# mat.fill(mat.dtype.type(20.))
19-
# mat_copy = mat.copy()
20-
# assert((mat == mat_copy).all())
21-
# assert(not (mat != mat_copy).all())
17+
# if version.parse(np.__version__) >= version.parse("1.21.0"):
18+
# # check if it fixes for new version of NumPy
19+
# mat.fill(mat.dtype.type(20.0))
20+
# mat_copy = mat.copy()
21+
# assert (mat == mat_copy).all()
22+
# assert not (mat != mat_copy).all()
2223

2324
mat_op = mat + mat
2425
mat_op = mat.copy(order="F") + mat.copy(order="C")
@@ -28,7 +29,7 @@ def test(dtype):
2829
mat_op = mat.dot(mat.T)
2930
mat_op = mat / mat
3031

31-
mat_op = -mat
32+
mat_op = -mat # noqa
3233

3334
assert (mat >= mat).all()
3435
assert (mat <= mat).all()
@@ -47,7 +48,7 @@ def test_cast(from_dtype, to_dtype):
4748
np.can_cast(from_dtype, to_dtype)
4849

4950
from_mat = np.zeros((rows, cols), dtype=from_dtype)
50-
to_mat = from_mat.astype(dtype=to_dtype)
51+
to_mat = from_mat.astype(dtype=to_dtype) # noqa
5152

5253

5354
test(user_type.CustomDouble)

0 commit comments

Comments
 (0)