Skip to content

Commit 724f989

Browse files
committed
fix flake8 issues for the learner tests
1 parent 4fe50d0 commit 724f989

7 files changed

Lines changed: 16 additions & 26 deletions

File tree

adaptive/tests/test_average_learner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_avg_std_and_npoints():
3030
# This will add 5000 points at random values of n.
3131
# It could try to readd already evaluated points.
3232

33-
n = random.randint(0, 2*300)
33+
n = random.randint(0, 2 * 300)
3434
value = random.random()
3535

3636
# With 10% chance None is added to simulate asking that point.

adaptive/tests/test_cquad.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
eps = np.spacing(1)
1414

1515

16-
def rolling_shuffle(nums, size):
17-
for i in range(len(nums) - size):
18-
x = nums[i:i+size+1]
19-
random.shuffle(x)
20-
nums[i:i+size+1] = x
21-
return nums
22-
23-
2416
def run_integrator_learner(f, a, b, tol, n):
2517
learner = IntegratorLearner(f, bounds=(a, b), tol=tol)
2618
for _ in range(n):
@@ -73,6 +65,7 @@ def same_ivals(f, a, b, tol):
7365

7466
return equal_ivals(learner.ivals, ivals, verbose=True)
7567

68+
7669
# XXX: This *should* pass (https://gitlab.kwant-project.org/qt/adaptive/issues/84)
7770
@pytest.mark.xfail
7871
def test_that_gives_same_intervals_as_reference_implementation():
@@ -162,7 +155,6 @@ def test_adding_points_and_skip_one_point():
162155
np.testing.assert_almost_equal(learner.igral, learner2.igral)
163156

164157

165-
166158
# XXX: This *should* pass (https://gitlab.kwant-project.org/qt/adaptive/issues/84)
167159
@pytest.mark.xfail
168160
def test_tell_in_random_order(first_add_33=False):
@@ -224,7 +216,6 @@ def test_tell_in_random_order(first_add_33=False):
224216
assert np.isfinite(l.err)
225217

226218

227-
228219
# XXX: This *should* pass (https://gitlab.kwant-project.org/qt/adaptive/issues/84)
229220
@pytest.mark.xfail
230221
def test_tell_in_random_order_first_add_33():

adaptive/tests/test_learner1d.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55

66
from ..learner import Learner1D
7-
from ..runner import simple, replay_log
7+
from ..runner import simple
88

99

1010
def test_pending_loss_intervals():
@@ -200,7 +200,8 @@ def test_small_deviations():
200200

201201
def test_uniform_sampling1D_v2():
202202
def check(known, expect):
203-
def f(x): return x
203+
def f(x):
204+
return x
204205
learner = Learner1D(f, bounds=(-1, 1))
205206
for x in known:
206207
learner.tell(x, f(x))
@@ -241,8 +242,8 @@ def test_tell_many():
241242
def f(x, offset=0.123214):
242243
a = 0.01
243244
return (np.sin(x**2) + np.sin(x**5)
244-
+ a**2 / (a**2 + (x - offset)**2)
245-
+ x**2 + 1e-5 * x**3)
245+
+ a**2 / (a**2 + (x - offset)**2)
246+
+ x**2 + 1e-5 * x**3)
246247

247248
def f_vec(x, offset=0.123214):
248249
a = 0.01

adaptive/tests/test_learners.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
import pytest
1313

14-
from ..learner import *
15-
from ..runner import simple, replay_log
14+
from ..learner import AverageLearner, BalancingLearner, Learner1D, Learner2D, LearnerND
15+
from ..runner import simple
1616

1717

1818
def generate_random_parametrization(f):

adaptive/tests/test_runner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import concurrent.futures as concurrent
43
import asyncio
54

65
from ..learner import Learner2D

adaptive/tests/test_skopt_learner.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import random
43
import numpy as np
54

65
import pytest

adaptive/tests/test_triangulation.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from collections import defaultdict, Counter
1+
from collections import Counter
22
from math import factorial
33
import itertools
44
import pytest
@@ -297,20 +297,20 @@ def test_triangulation_is_deterministic(dim):
297297
@with_dimension
298298
def test_initialisation_raises_when_not_enough_points(dim):
299299
deficient_simplex = _make_standard_simplex(dim)[:-1]
300-
300+
301301
with pytest.raises(ValueError):
302302
Triangulation(deficient_simplex)
303303

304304

305305
@with_dimension
306306
def test_initialisation_raises_when_points_coplanar(dim):
307307
zero_volume_simplex = _make_standard_simplex(dim)[:-1]
308-
308+
309309
new_point1 = np.average(zero_volume_simplex, axis=0)
310310
new_point2 = np.sum(zero_volume_simplex, axis=0)
311-
zero_volume_simplex = np.vstack((zero_volume_simplex,
311+
zero_volume_simplex = np.vstack((zero_volume_simplex,
312312
new_point1, new_point2))
313-
313+
314314
with pytest.raises(ValueError):
315315
Triangulation(zero_volume_simplex)
316316

@@ -326,6 +326,6 @@ def test_initialisation_accepts_more_than_one_simplex(dim):
326326
simplex1 = tuple(range(dim+1))
327327
simplex2 = tuple(range(1, dim+2))
328328

329-
_check_triangulation_is_valid(tri)
330-
329+
_check_triangulation_is_valid(tri)
330+
331331
assert tri.simplices == {simplex1, simplex2}

0 commit comments

Comments
 (0)