8000 linters: add ruff & isort by nim65s · Pull Request #441 · stack-of-tasks/eigenpy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

linters: add ruff & isort #441

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
# pre-commit run -a (Guilhem Saurel, 2022-07-27)
4af05ec6781f9da65b81af8e3af8d69213f99e85

# pre-commit run -a (Guilhem Saurel, 2024-02-17)
48fb48c83f0456de2fb612ef55df8ad789824d87

# pre-commit run -a (Guilhem Saurel, 2024-02-19)
0bae435330ee475f8dbb11bf5e672284d294d9b3
45 changes: 27 additions & 18 deletions .pre-commit-config.yaml
8000
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
ci:
autoupdate_branch: 'devel'
autoupdate_branch: devel
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
args: ['--style={BasedOnStyle: Google, SortIncludes: false, Standard: Cpp03}']
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.2.0
hooks:
- id: black
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.2
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix
- id: ruff-format
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- repo: https://github.com/pappasam/toml-sort
rev: v0.23.1
hooks:
- id: toml-sort-fix
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v17.0.6
hooks:
- id: clang-format
args:
- '--style={BasedOnStyle: Google, SortIncludes: false, Standard: Cpp03}'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Support for `std::unique_ptr` as a return types with `StdUniquePtrCallPolicies` and `boost::python::default_call_policies` ([#433](https://github.com/stack-of-tasks/eigenpy/pull/433))
- Support for `std::unique_ptr` as an internal reference with `ReturnInternalStdUniquePtr` ([#433](https://github.com/stack-of-tasks/eigenpy/pull/433))
- Support for `Eigen::Simplicial{LLT,LDLT}` and `Eigen::Cholmod{Simplicial,Supernodal}{LLT,LDLT}` Cholesky de compositions ([#438](https://github.com/stack-of-tasks/eigenpy/pull/438))
- Switch to ruff for lints, format, and import sort ([#441](https://github.com/stack-of-tasks/eigenpy/pull/441))

### Fixed
- Fix the issue of missing exposition of Eigen types with __int64 scalar type ([#426](https://github.com/stack-of-tasks/eigenpy/pull/426))
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ EigenPy — Versatile and efficient Python bindings between Numpy and Eigen
<a href="https://anaconda.org/conda-forge/eigenpy"><img src="https://img.shields.io/conda/vn/conda-forge/eigenpy.svg" alt="Conda Version"/></a>
<a href="https://badge.fury.io/py/eigenpy"><img src="https://badge.fury.io/py/eigenpy.svg" alt="PyPI version"></a>
<a href="https://github.com/psf/black"><img src="https://img.shields.io/badge/code%20style-black-000000.svg" alt="Code style: black"></a>
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Linter: ruff"></a>
</p>

**EigenPy** is an open-source framework that allows the binding of the famous [Eigen](http://eigen.tuxfamily.org) C++ library in Python via Boost.Python.
Expand Down
8 changes: 3 additions & 5 deletions benchmarks/bench-switch.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from __future__ import print_function

import eigenpy
import numpy as np

import time # noqa
import timeit # noqa

import numpy as np
from IPython import get_ipython

import eigenpy

ipython = get_ipython()

quat = eigenpy.Quaternion()
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tool.ruff]
extend-exclude = ["cmake"]

[tool.ruff.lint]
extend-select = ["I", "NPY", "RUF", "UP", "W"]

[tool.ruff.lint.isort]
known-first-party = ["eigenpy"]

[tool.tomlsort]
all = true
2 changes: 1 addition & 1 deletion python/eigenpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
#

from .eigenpy_pywrap import * # noqa
from .eigenpy_pywrap import __version__, __raw_version__ # noqa
from .eigenpy_pywrap import __raw_version__, __version__ # noqa
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import eigenpy

import numpy as np
from scipy.sparse import csc_matrix

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
rng = np.random.default_rng()
A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

A = csc_matrix(A)

llt = eigenpy.CholmodSimplicialLDLT(A)

assert llt.info() == eigenpy.ComputationInfo.Success

X = np.random.rand(dim, 20)
X = rng.rand((dim, 20))
B = A.dot(X)
X_est = llt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import eigenpy

import numpy as np
from scipy.sparse import csc_matrix

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
rng = np.random.default_rng()

A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

A = csc_matrix(A)

llt = eigenpy.CholmodSimplicialLLT(A)

assert llt.info() == eigenpy.ComputationInfo.Success

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = llt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import eigenpy

import numpy as np
from scipy.sparse import csc_matrix

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
rng = np.random.default_rng()

A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

A = csc_matrix(A)

llt = eigenpy.CholmodSupernodalLLT(A)

assert llt.info() == eigenpy.ComputationInfo.Success

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = llt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
12 changes: 7 additions & 5 deletions unittest/python/decompositions/sparse/test_Accelerate.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import eigenpy

import numpy as np
from scipy.sparse import csc_matrix

import eigenpy

rng = np.random.default_rng()


def test(SolverType: type):
dim = 100
A = np.random.rand(dim, dim)
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

A = csc_matrix(A)

llt = SolverType(A)

assert llt.info() == eigenpy.ComputationInfo.Success

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = llt.solve(B)
# import pdb; pdb.set_trace()
Expand Down
12 changes: 7 additions & 5 deletions unittest/python/decompositions/sparse/test_SimplicialLDLT.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import eigenpy

import numpy as np
from scipy.sparse import csc_matrix

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
rng = np.random.default_rng()

A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

A = csc_matrix(A)

Expand All @@ -20,7 +22,7 @@
LDU = L @ D @ U
assert eigenpy.is_approx(LDU.toarray(), A.toarray())

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = ldlt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
12 changes: 7 additions & 5 deletions unittest/python/decompositions/sparse/test_SimplicialLLT.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import eigenpy

import numpy as np
from scipy.sparse import csc_matrix

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
rng = np.random.default_rng()

A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

A = csc_matrix(A)

Expand All @@ -19,7 +21,7 @@
LU = L @ U
assert eigenpy.is_approx(LU.toarray(), A.toarray())

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = llt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
10 changes: 6 additions & 4 deletions unittest/python/test_LDLT.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import eigenpy
import numpy as np

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
rng = np.random.default_rng()

A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

ldlt = eigenpy.LDLT(A)

Expand All @@ -16,7 +18,7 @@
np.transpose(P).dot(L.dot(np.diag(D).dot(np.transpose(L).dot(P)))), A
)

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = ldlt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
11 changes: 6 additions & 5 deletions unittest/python/test_LLT.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import eigenpy

import numpy as np

import eigenpy

dim = 100
A = np.random.rand(dim, dim)
rng = np.random.default_rng()

A = (A + A.T) * 0.5 + np.diag(10.0 + np.random.rand(dim))
A = rng.random((dim, dim))
A = (A + A.T) * 0.5 + np.diag(10.0 + rng.random(dim))

llt = eigenpy.LLT(A)

L = llt.matrixL()
assert eigenpy.is_approx(L.dot(np.transpose(L)), A)

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = llt.solve(B)
assert eigenpy.is_approx(X, X_est)
Expand Down
6 changes: 4 additions & 2 deletions unittest/python/test_MINRES.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import eigenpy
import numpy as np

import eigenpy

dim = 100
rng = np.random.default_rng()
A = np.eye(dim)

minres = eigenpy.MINRES(A)

X = np.random.rand(dim, 20)
X = rng.random((dim, 20))
B = A.dot(X)
X_est = minres.solve(B)
print("A.dot(X_est):", A.dot(X_est))
Expand Down
9 changes: 4 additions & 5 deletions unittest/python/test_complex.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from __future__ import print_function

import numpy as np
from complex import real, imag, ascomplex
from complex import ascomplex, imag, real

rows = 10
cols = 20
rng = np.random.default_rng()


def test(dtype):
Z = np.zeros((rows, cols), dtype=dtype)
Z.real = np.random.rand(rows, cols)
Z.imag = np.random.rand(rows, cols)
Z.real = rng.random((rows, cols))
Z.imag = rng.random((rows, cols))

Z_real = real(Z)
assert (Z_real == Z.real).all()
Expand Down
2 changes: 0 additions & 2 deletions unittest/python/test_dimensions.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import print_function

import eigenpy

quat = eigenpy.Quaternion()
Expand Down
Loading
0