Skip to content

Feat apply ruff #497

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 69 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
724e59b
chore: add ruff
phi-friday Jul 11, 2024
23290a9
chore: init ruff config
phi-friday Jul 11, 2024
536ef27
chore: update ruff pydocstyle config
phi-friday Jul 11, 2024
479f495
chore: update ruff rules
phi-friday Jul 11, 2024
7f47a03
chore: update ruff exclude
phi-friday Jul 11, 2024
393c65d
fix: init format & check(fix)
phi-friday Jul 11, 2024
e16ce00
fix: constraint
phi-friday Jul 11, 2024
5b7eb9f
fix: domain_reduction(without E501)
phi-friday Jul 11, 2024
25ed03c
fix: update ruff rule(TRY -> TRY002)
phi-friday Jul 11, 2024
f8160f6
fix: target_space(without E501)
phi-friday Jul 11, 2024
360d2ba
fix: init tests
phi-friday Jul 11, 2024
d413d01
fix: test_notebooks_run.py
phi-friday Jul 11, 2024
e353169
fix: test_observer
phi-friday Jul 11, 2024
abedcff
fix: test_seq_domain_red
phi-friday Jul 11, 2024
d82650b
fix: test_target_space
phi-friday Jul 11, 2024
15a62e6
fix: E501
phi-friday Jul 11, 2024
ddeb03a
chore: add pre-commit
phi-friday Jul 11, 2024
6754176
chore: update ruff
phi-friday Jul 11, 2024
cf6a5f4
chore: add precommit config
phi-friday Jul 11, 2024
571fe89
feat: add format & lint action
phi-friday Jul 11, 2024
d88d134
test
phi-friday Jul 11, 2024
edf85b2
fix: 3.10 -> 3.9(minimum)
phi-friday Jul 11, 2024
9f7c30a
chore: update ruff config
phi-friday Jul 11, 2024
4153f8b
chore: update ruff config
phi-friday Jul 11, 2024
4737456
revert check docstring(not yet D rule)
phi-friday Jul 11, 2024
b9a9e56
chore: revert pydocstyle
phi-friday Jul 11, 2024
601ac0c
fix: add coverage exclude_lines
phi-friday Jul 11, 2024
3782729
SIM
phi-friday Jul 11, 2024
e2802a1
S
phi-friday Jul 11, 2024
06267c7
DTZ
phi-friday Jul 11, 2024
db588fe
EM
phi-friday Jul 11, 2024
cefe0f8
LOG
phi-friday Jul 11, 2024
af70db1
G
phi-friday Jul 11, 2024
0f80750
PIE
phi-friday Jul 11, 2024
a93405c
Q
phi-friday Jul 11, 2024
069d879
RET
phi-friday Jul 11, 2024
f3176c3
TID
phi-friday Jul 11, 2024
0e08ea6
PTH
phi-friday Jul 11, 2024
1dd2304
F
phi-friday Jul 11, 2024
b23e17f
NPY
phi-friday Jul 11, 2024
6afdd5e
PERF
phi-friday Jul 11, 2024
ff1f055
FURB
phi-friday Jul 11, 2024
4636b9a
RUF
phi-friday Jul 11, 2024
223cc57
D
phi-friday Jul 11, 2024
627f14d
chore: rm pydocstyle action
phi-friday Jul 11, 2024
b012d6c
chore: rm pydocstyle
phi-friday Jul 11, 2024
4f054a3
fix: render path only once
phi-friday Jul 11, 2024
c86d195
ISC
phi-friday Jul 12, 2024
b318e78
fix: pr447
phi-friday Jul 13, 2024
4025a49
init
phi-friday Jul 13, 2024
553eefe
fix: acquisition
phi-friday Jul 13, 2024
b1db8b8
fix: bayesian_optimization
phi-friday Jul 13, 2024
2d7028c
fix: util
phi-friday Jul 13, 2024
74589b5
fix: acquisition
phi-friday Jul 13, 2024
ae1e94b
fix: test_bayesian_optimization
phi-friday Jul 13, 2024
75d74ab
fix: test_constraint
phi-friday Jul 13, 2024
cb2e93b
fix: test_util
phi-friday Jul 13, 2024
edb015c
fix: _update_params
phi-friday Jul 13, 2024
b39fd8f
feat: scripts
phi-friday Jul 13, 2024
e78cc2d
fix: reviews
phi-friday Jul 13, 2024
c3835d3
test: upper_confidence_bound_invalid_kappa_error
phi-friday Jul 13, 2024
980c603
chore: update ruff
phi-friday Jul 14, 2024
1d33643
fix: acquisition
phi-friday Jul 17, 2024
39ea506
fix: util
phi-friday Jul 17, 2024
c477ebc
fix: relative -> absolute
phi-friday Jul 17, 2024
d305c1b
fix: import error
phi-friday Jul 17, 2024
e14c3a9
fix: review
phi-friday Jul 17, 2024
1e48510
fix: review
phi-friday Jul 17, 2024
ed5a224
fix: rm unused func
phi-friday Jul 17, 2024
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
Prev Previous commit
Next Next commit
fix: init tests
  • Loading branch information
phi-friday committed Jul 17, 2024
commit 360d2ba751f9fa8be96e0689514b4cdf754d9b2f
30 changes: 17 additions & 13 deletions tests/test_notebooks_run.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
"""
collect all notebooks in examples, and check that they run without error
"""
from __future__ import annotations

from glob import glob
from pathlib import Path

import nbformat
from matplotlib import pyplot as plt
from nbconvert.preprocessors import ExecutePreprocessor
from pathlib import Path
from glob import glob
from matplotlib import pyplot as plt # this script doesn't use this but the notebooks do

this_file_loc = Path(__file__).parent

def check_notebook_runs(notebook_loc):

print(f'running: {notebook_loc}...')
def check_notebook_runs(notebook_loc):
print(f"running: {notebook_loc}...")
try:
with open(notebook_loc, encoding='utf8') as f:
with open(notebook_loc, encoding="utf8") as f:
nb = nbformat.read(f, as_version=4)
ep = ExecutePreprocessor(timeout=600, kernel_name='python3')
ep.preprocess(nb, {'metadata': {'path': Path(notebook_loc).parent}})
ep = ExecutePreprocessor(timeout=600, kernel_name="python3")
ep.preprocess(nb, {"metadata": {"path": Path(notebook_loc).parent}})
except Exception as e:
raise Exception(f'failed to run notebook {notebook_loc}')
print(f'success!')
raise Exception(f"failed to run notebook {notebook_loc}")
print(f"success!")


def test_all_notebooks_run():
# get all notebooks:
notebooks = glob(str(this_file_loc.parent / 'examples' / '*.ipynb'))
notebooks_not_to_run = ['put_notebooks_to_skip_here']
notebooks = glob(str(this_file_loc.parent / "examples" / "*.ipynb"))
notebooks_not_to_run = ["put_notebooks_to_skip_here"]
for notebook in notebooks:
if any([nb in notebook for nb in notebooks_not_to_run]):
continue
check_notebook_runs(notebook)
check_notebook_runs(notebook)
41 changes: 22 additions & 19 deletions tests/test_observer.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
from bayes_opt.bayesian_optimization import Observable
from bayes_opt.observer import _Tracker
from bayes_opt.event import Events
from __future__ import annotations

import os

from bayes_opt.bayesian_optimization import Observable
from bayes_opt.event import Events
from bayes_opt.observer import _Tracker

EVENTS = ["a", "b", "c"]


class SimpleObserver():
class SimpleObserver:
def __init__(self):
self.counter = 0

Expand All @@ -20,13 +22,13 @@ def test_get_subscribers():
observable = Observable(events=EVENTS)
observable.subscribe("a", observer)

assert observer in observable.get_subscribers('a')
assert observer not in observable.get_subscribers('b')
assert observer not in observable.get_subscribers('c')
assert observer in observable.get_subscribers("a")
assert observer not in observable.get_subscribers("b")
assert observer not in observable.get_subscribers("c")

assert len(observable.get_subscribers('a')) == 1
assert len(observable.get_subscribers('b')) == 0
assert len(observable.get_subscribers('c')) == 0
assert len(observable.get_subscribers("a")) == 1
assert len(observable.get_subscribers("b")) == 0
assert len(observable.get_subscribers("c")) == 0


def test_unsubscribe():
Expand All @@ -36,8 +38,8 @@ def test_unsubscribe():
observable.subscribe("a", observer)
observable.unsubscribe("a", observer)

assert observer not in observable.get_subscribers('a')
assert len(observable.get_subscribers('a')) == 0
assert observer not in observable.get_subscribers("a")
assert len(observable.get_subscribers("a")) == 0


def test_dispatch():
Expand All @@ -51,17 +53,17 @@ def test_dispatch():
assert observer_a.counter == 0
assert observer_b.counter == 0

observable.dispatch('b')
observable.dispatch("b")
assert observer_a.counter == 0
assert observer_b.counter == 1

observable.dispatch('a')
observable.dispatch('b')
observable.dispatch("a")
observable.dispatch("b")
assert observer_a.counter == 1
assert observer_b.counter == 2

observable.dispatch('a')
observable.dispatch('c')
observable.dispatch("a")
observable.dispatch("c")
assert observer_a.counter == 2
assert observer_a.counter == 2

Expand Down Expand Up @@ -110,14 +112,15 @@ def max(self):

tracker._time_metrics()
assert start_time == tracker._start_time
if not 'win' in os.sys.platform:
if "win" not in os.sys.platform:
assert previous_time < tracker._previous_time


if __name__ == '__main__':
if __name__ == "__main__":
r"""
CommandLine:
python tests/test_observer.py
"""
import pytest

pytest.main([__file__])
7 changes: 4 additions & 3 deletions tests/test_queue.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from __future__ import annotations

import pytest

from bayes_opt.bayesian_optimization import Queue


Expand All @@ -19,7 +22,6 @@ def test_add():


def test_queue():

queue = Queue()

with pytest.raises(StopIteration):
Expand All @@ -40,8 +42,7 @@ def test_queue():
assert len(queue) == 0



if __name__ == '__main__':
if __name__ == "__main__":
r"""
CommandLine:
python tests/test_observer.py
Expand Down
Loading