Skip to content

Commit

Permalink
update: fix dependency (#65)
Browse files Browse the repository at this point in the history
* update: fix dependency

* fix: update CI

* fix: CI check 3.9

* fix: painted it black

* fix: correct install in CI

* fix: update poetry lock

* fix: update code to new numpy version

---------

Co-authored-by: Sylvain Chevallier <[email protected]>
  • Loading branch information
sylvchev and Sylvain Chevallier authored Oct 12, 2023
1 parent 87e7d6c commit a15cf66
Show file tree
Hide file tree
Showing 5 changed files with 850 additions and 656 deletions.
35 changes: 19 additions & 16 deletions .github/workflows/test_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,34 @@ jobs:
strategy:
fail-fast: true
matrix:
python_version: [3.7, 3.8, 3.9]
python_version: [3.9]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: "Setup Python"
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python_version }}
- uses: pre-commit/[email protected]
- name: "Install dependencies"
shell: bash
run: |
python -m pip install --upgrade pip poetry wheel flake8 coverage
poetry config virtualenvs.create false
poetry install
- name: "Check style"
shell: bash
run: |
flake8

- uses: pre-commit/[email protected]

- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true

- name: Install MDLA
run: poetry install --no-interaction --with dev

- name: "Run tests"
shell: bash
run: |
pytest --cov=./ --cov-report=xml
poetry run pytest --cov=./ --cov-report=xml
- name: "Coverage"
uses: codecov/codecov-action@v1
uses: codecov/codecov-action@v3
with:
files: ./coverage.xml
flags: unittests
Expand Down
24 changes: 17 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,31 @@ repos:
- id: mixed-line-ending

- repo: https://github.com/psf/black
rev: 20.8b1
rev: 23.9.1
hooks:
- id: black
language_version: python
language_version: python3.9

- repo: https://github.com/pycqa/isort
rev: 5.7.0
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.0
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]
additional_dependencies:
[
"flake8-blind-except",
"flake8-docstrings",
"flake8-bugbear",
"flake8-comprehensions",
"flake8-docstrings",
"flake8-implicit-str-concat",
"pydocstyle>=5.0.0",
]
exclude: ^docs/ | ^setup\.py$ |

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.2.1
Expand Down
14 changes: 6 additions & 8 deletions mdla/mdla.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def _get_learning_rate(iteration, max_iteration, learning_rate):
return 0.0
last_iterations = np.floor(max_iteration * 2.0 / 3.0)
if iteration >= last_iterations:
return last_iterations ** learning_rate
return last_iterations**learning_rate
else:
return (iteration + 1) ** learning_rate

Expand Down Expand Up @@ -107,7 +107,7 @@ def _multivariate_OMP(signal, dictionary, n_nonzero_coefs=None, verbose=False):
if verbose >= 4:
print("[M-OMP # 0 ] signal is")
print(residual)
Ainv = np.zeros((n_kernels, n_kernels), np.float)
Ainv = np.zeros((n_kernels, n_kernels), float)
Ainv[0, 0] = 1.0

# First iteration
Expand Down Expand Up @@ -145,8 +145,8 @@ def _multivariate_OMP(signal, dictionary, n_nonzero_coefs=None, verbose=False):
print("[M-OMP # 0 ] residual is now")
print(residual)

signal_energy = (signal ** 2).sum(1).mean()
residual_energy = (residual ** 2).sum(1).mean()
signal_energy = (signal**2).sum(1).mean()
residual_energy = (residual**2).sum(1).mean()

if verbose >= 3:
print(
Expand Down Expand Up @@ -213,7 +213,7 @@ def _multivariate_OMP(signal, dictionary, n_nonzero_coefs=None, verbose=False):
Ainv[0:atoms_in_estimate, atoms_in_estimate : atoms_in_estimate + 1] = -beta * b
Ainv[atoms_in_estimate, atoms_in_estimate] = beta
decomposition[atoms_in_estimate] = np.array(
[alpha, k_off, k_selected], dtype=np.float64
alpha.flatten().tolist() + [k_off, k_selected], dtype=np.float64
)
atoms_in_estimate += 1
selected_list = np.vstack((selected_list, selected_atom.flatten()))
Expand All @@ -230,7 +230,7 @@ def _multivariate_OMP(signal, dictionary, n_nonzero_coefs=None, verbose=False):
residual = signal - estimated_signal

if verbose >= 3:
residual_energy = (residual ** 2).sum(1).mean()
residual_energy = (residual**2).sum(1).mean()
print(
"[M-OMP #",
atoms_in_estimate - 1,
Expand Down Expand Up @@ -1335,7 +1335,6 @@ def __init__(
random_state=None,
callback=None,
):

self._set_mdla_params(
n_kernels, n_nonzero_coefs, kernel_init_len, n_jobs, learning_rate
)
Expand Down Expand Up @@ -1504,7 +1503,6 @@ def __init__(
learning_rate=None,
callback=None,
):

self._set_mdla_params(
n_kernels, n_nonzero_coefs, kernel_init_len, n_jobs, learning_rate
)
Expand Down
Loading

0 comments on commit a15cf66

Please sign in to comment.