Skip to content

Commit

Permalink
Prevent yesqa from removing necessary qa's (#40)
Browse files Browse the repository at this point in the history
* Update pre-commits

* Remove `flake8-mock` causing issues with `yesqa`

* Update `additional_dependencies`.

* Use `codecov` action

Co-authored-by: Michal Klein <michal.klein@protonmail.com>
  • Loading branch information
msmdev and michalk8 committed Oct 10, 2022
1 parent ec4b04e commit 0d027d1
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 34 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ jobs:
USE_SLEPC: ${{ matrix.use_slepc }}

- name: Upload coverage
if: success()
env:
CODECOV_NAME: ${{ matrix.os }}-${{ matrix.python }}-{{ matrix.use_slepc }}
run: |
codecov --no-color --required --flags unittests
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests
name: ${{ matrix.os }}-${{ matrix.python }}-{{ matrix.use_slepc }}
env_vars: OS,PYTHON
fail_ci_if_error: false
verbose: true

deploy:
needs: [lint, test]
Expand Down
38 changes: 17 additions & 21 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,33 @@ default_stages:
minimum_pre_commit_version: 2.9.0
repos:
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
rev: v0.982
hooks:
- id: mypy
additional_dependencies: [numpy==1.20.0, scipy>=1.6.0]
- repo: https://github.com/psf/black
rev: 20.8b1
rev: 22.10.0
hooks:
- id: black
additional_dependencies: ['click==8.0.1', toml]
additional_dependencies: [toml]
- repo: https://github.com/timothycrosley/isort
rev: 5.7.0
rev: 5.10.1
hooks:
- id: isort
additional_dependencies: [toml]
args: [--order-by-type]
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
rev: v1.4.0
hooks:
- id: yesqa
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-mock, flake8-string-format]
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-string-format]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v1.6.1
rev: v2.4.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '4', --preserve-quotes]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
rev: v4.3.0
hooks:
- id: detect-private-key
- id: no-commit-to-branch
Expand All @@ -57,37 +57,33 @@ repos:
- id: check-toml
- id: requirements-txt-fixer
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.4
rev: 3.9.2
hooks:
- id: flake8
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-mock, flake8-string-format]
additional_dependencies: [flake8-tidy-imports, flake8-docstrings, flake8-rst-docstrings, flake8-comprehensions, flake8-bugbear, flake8-logging-format, flake8-blind-except, flake8-builtins, flake8-pytest-style, flake8-string-format]
- repo: https://github.com/myint/autoflake
rev: v1.4
rev: v1.7.1
hooks:
- id: autoflake
args: [--in-place, --remove-all-unused-imports, --remove-unused-variable, --ignore-init-module-imports]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 2.1.4
rev: 3.0.0
hooks:
- id: script-must-have-extension
name: Check executable files use .sh extension
types: [shell, executable]
- repo: https://github.com/myint/rstcheck
rev: 3f92957478422df87bd730abde66f089cc1ee19b
hooks:
- id: rstcheck
- repo: https://github.com/asottile/blacken-docs
rev: v1.9.1
rev: v1.12.1
hooks:
- id: blacken-docs
additional_dependencies: [black==20.8b1]
additional_dependencies: [black==22.10.0]
- repo: https://github.com/asottile/pyupgrade
rev: v2.7.4
rev: v3.0.0
hooks:
- id: pyupgrade
args: [--py3-plus, --py37-plus]
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.7.0
rev: v1.9.0
hooks:
- id: python-no-eval
- id: python-use-type-annotations
Expand All @@ -96,6 +92,6 @@ repos:
- id: rst-directive-colons
- id: rst-inline-touching-normal
- repo: https://github.com/PyCQA/doc8
rev: 0.9.0a1
rev: v1.0.0
hooks:
- id: doc8
3 changes: 0 additions & 3 deletions .rstcheck.cfg

This file was deleted.

4 changes: 2 additions & 2 deletions pygpcca/_gpcca.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def _objective(alpha: np.ndarray, X: np.ndarray) -> float:
rot_mat = np.zeros((m, m), dtype=np.float64)

# Sanity checks.
if alpha.shape[0] != k ** 2:
if alpha.shape[0] != k**2:
raise ValueError(
"The shape of alpha doesn't match with the shape of X: "
f"It is not a ({k}^2,)-vector, but of dimension {alpha.shape}. X is of shape `{X.shape}`."
Expand Down Expand Up @@ -514,7 +514,7 @@ def _opt_soft(X: np.ndarray, rot_matrix: np.ndarray) -> Tuple[np.ndarray, np.nda

# Now reshape rot_crop_matrix into a linear vector alpha.
k = m - 1
alpha = np.reshape(rot_crop_matrix, k ** 2)
alpha = np.reshape(rot_crop_matrix, k**2)
# TODO: Implement Gauss Newton Optimization to speed things up esp. for m > 10
alpha, fopt, _, _, _ = fmin(_objective, alpha, args=(X,), full_output=True, disp=False)

Expand Down
2 changes: 1 addition & 1 deletion pygpcca/_sort_real_schur.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def rot(X: np.ndarray) -> np.ndarray:
s = 0.0
if X[0, 0] != X[1, 1]:
tau = (X[0, 1] + X[1, 0]) / (X[0, 0] - X[1, 1])
off = (tau ** 2 + 1) ** 0.5
off = (tau**2 + 1) ** 0.5
v = [tau - off, tau + off]
w = int(np.argmin(np.abs(v)))
c = 1.0 / (1.0 + v[w] ** 2) ** 0.5 # ... the cosine and sine as given in Section 2.3.1
Expand Down
4 changes: 2 additions & 2 deletions tests/test_gpcca.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ def test_objective_1(self, svecs_mu0: np.ndarray, A_mu0_init: np.ndarray, A_mu0:
alpha[j + i * (k - 1)] = A_mu0_init[i + 1, j + 1]

act_val = _objective(alpha, svecs_mu0)
exp_val = k - np.sum(np.true_divide(np.sum(A_mu0 ** 2, axis=0), A_mu0[0, :]))
exp_val = k - np.sum(np.true_divide(np.sum(A_mu0**2, axis=0), A_mu0[0, :]))

assert_allclose(act_val, exp_val)

Expand All @@ -390,7 +390,7 @@ def test_objective_2(self, svecs_mu1000: np.ndarray, A_mu1000_init: np.ndarray,
alpha[j + i * (k - 1)] = A_mu1000_init[i + 1, j + 1]

act_val = _objective(alpha, svecs_mu1000)
exp_val = k - np.sum(np.true_divide(np.sum(A_mu1000 ** 2, axis=0), A_mu1000[0, :]))
exp_val = k - np.sum(np.true_divide(np.sum(A_mu1000**2, axis=0), A_mu1000[0, :]))

assert_allclose(act_val, exp_val)

Expand Down

0 comments on commit 0d027d1

Please sign in to comment.