Skip to content

Commit 3dab38a

Browse files
committed
run pre-commit run --all
1 parent afcd8bd commit 3dab38a

33 files changed

+23
-69
lines changed

adaptive/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from contextlib import suppress
42

53
from adaptive import learner, runner, utils

adaptive/_version.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# This file is part of 'miniver': https://github.com/jbweston/miniver
32
#
43
import os

adaptive/learner/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from contextlib import suppress
42

53
from adaptive.learner.average_learner import AverageLearner

adaptive/learner/average_learner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from math import sqrt
42

53
import numpy as np

adaptive/learner/balancing_learner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import itertools
42
from collections import defaultdict
53
from collections.abc import Iterable

adaptive/learner/base_learner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
# -*- coding: utf-8 -*-
2-
31
import abc
42
from contextlib import suppress
53
from copy import deepcopy
64

7-
from adaptive.utils import load, save, _RequireAttrsABCMeta
5+
from adaptive.utils import _RequireAttrsABCMeta, load, save
86

97

108
def uses_nth_neighbors(n):

adaptive/learner/data_saver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import functools
42
from collections import OrderedDict
53

adaptive/learner/integrator_coeffs.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Based on an adaptive quadrature algorithm by Pedro Gonnet
32

43
from collections import defaultdict

adaptive/learner/integrator_learner.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
# Based on an adaptive quadrature algorithm by Pedro Gonnet
32

43
import sys
@@ -572,9 +571,15 @@ def _get_data(self):
572571
)
573572

574573
def _set_data(self, data):
575-
self.priority_split, self.data, self.pending_points, self._stack, x_mapping, self.ivals, self.first_ival = (
576-
data
577-
)
574+
(
575+
self.priority_split,
576+
self.data,
577+
self.pending_points,
578+
self._stack,
579+
x_mapping,
580+
self.ivals,
581+
self.first_ival,
582+
) = data
578583

579584
# Add the pending_points to the _stack such that they are evaluated again
580585
for x in self.pending_points:

adaptive/learner/learner1D.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import itertools
42
import math
53
from collections.abc import Iterable

adaptive/learner/learner2D.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import itertools
42
import warnings
53
from collections import OrderedDict

adaptive/learner/learnerND.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import functools
42
import itertools
53
import random
@@ -340,8 +338,8 @@ def __init__(self, func, bounds, loss_per_simplex=None):
340338
self._min_value = None
341339
self._max_value = None
342340
self._output_multiplier = (
343-
1
344-
) # If we do not know anything, do not scale the values
341+
1 # If we do not know anything, do not scale the values
342+
)
345343
self._recompute_losses_factor = 1.1
346344

347345
# create a private random number generator with fixed seed

adaptive/learner/skopt_learner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
# -*- coding: utf-8 -*-
2-
31
import collections
42

53
import numpy as np
6-
from skopt import Optimizer
74

85
from adaptive.learner.base_learner import BaseLearner
96
from adaptive.notebook_integration import ensure_holoviews
107
from adaptive.utils import cache_latest
8+
from skopt import Optimizer
119

1210

1311
class SKOptLearner(Optimizer, BaseLearner):

adaptive/learner/triangulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def simplex_volume_in_embedding(vertices) -> float:
228228
# Make matrix and find volume
229229
sq_dists_mat = scipy.spatial.distance.squareform(bordered)
230230

231-
coeff = -(-2) ** (num_verts - 1) * factorial(num_verts - 1) ** 2
231+
coeff = -((-2) ** (num_verts - 1)) * factorial(num_verts - 1) ** 2
232232
vol_square = fast_det(sq_dists_mat) / coeff
233233

234234
if vol_square < 0:

adaptive/notebook_integration.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import asyncio
42
import datetime
53
import importlib

adaptive/runner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import abc
42
import asyncio
53
import concurrent.futures as concurrent

adaptive/tests/test_average_learner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import random
42

53
import numpy as np

adaptive/tests/test_balancing_learner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import pytest
42

53
from adaptive.learner import BalancingLearner, Learner1D

adaptive/tests/test_cquad.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
from functools import partial
42
from operator import attrgetter
53

adaptive/tests/test_learner1d.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import random
42

53
import numpy as np

adaptive/tests/test_learnernd.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import numpy as np
42
import scipy.spatial
53

adaptive/tests/test_learners.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import collections
42
import functools as ft
53
import inspect
@@ -129,15 +127,15 @@ def linear_with_peak(x, d: uniform(-1, 1)):
129127
def ring_of_fire(xy, d: uniform(0.2, 1)):
130128
a = 0.2
131129
x, y = xy
132-
return x + math.exp(-(x ** 2 + y ** 2 - d ** 2) ** 2 / a ** 4)
130+
return x + math.exp(-((x ** 2 + y ** 2 - d ** 2) ** 2) / a ** 4)
133131

134132

135133
@learn_with(LearnerND, bounds=((-1, 1), (-1, 1), (-1, 1)))
136134
@learn_with(SequenceLearner, sequence=np.random.rand(1000, 3))
137135
def sphere_of_fire(xyz, d: uniform(0.2, 1)):
138136
a = 0.2
139137
x, y, z = xyz
140-
return x + math.exp(-(x ** 2 + y ** 2 + z ** 2 - d ** 2) ** 2 / a ** 4) + z ** 2
138+
return x + math.exp(-((x ** 2 + y ** 2 + z ** 2 - d ** 2) ** 2) / a ** 4) + z ** 2
141139

142140

143141
@learn_with(SequenceLearner, sequence=range(1000))

adaptive/tests/test_notebook_integration.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import ipykernel.iostream
42
import zmq
53

adaptive/tests/test_runner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import asyncio
42
import time
53

adaptive/tests/test_skopt_learner.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import numpy as np
42
import pytest
53

adaptive/tests/test_triangulation.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import itertools
42
from collections import Counter
53
from math import factorial

adaptive/tests/unit/test_learnernd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def ring_of_fire(xy):
1212
a = 0.2
1313
d = 0.7
1414
x, y = xy
15-
return x + math.exp(-(x ** 2 + y ** 2 - d ** 2) ** 2 / a ** 4)
15+
return x + math.exp(-((x ** 2 + y ** 2 - d ** 2) ** 2) / a ** 4)
1616

1717

1818
def test_learnerND_inits_loss_depends_on_neighbors_correctly():

adaptive/tests/unit/test_learnernd_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
def ring_of_fire(xy, d=0.75):
1212
a = 0.2
1313
x, y = xy
14-
return x + math.exp(-(x ** 2 + y ** 2 - d ** 2) ** 2 / a ** 4)
14+
return x + math.exp(-((x ** 2 + y ** 2 - d ** 2) ** 2) / a ** 4)
1515

1616

1717
def test_learnerND_runs_to_10_points():

adaptive/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
31
import abc
42
import functools
53
import gzip

benchmarks/benchmarks/benchmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def f_1d(x, offset=offset):
1515
def f_2d(xy):
1616
x, y = xy
1717
a = 0.2
18-
return x + np.exp(-(x ** 2 + y ** 2 - 0.75 ** 2) ** 2 / a ** 4)
18+
return x + np.exp(-((x ** 2 + y ** 2 - 0.75 ** 2) ** 2) / a ** 4)
1919

2020

2121
class TimeLearner1D:

docs/logo.py

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

99
sys.path.insert(0, os.path.abspath("..")) # to get adaptive on the path
1010

11-
import adaptive # noqa: E402
11+
import adaptive # noqa: E402, isort:skip
1212

1313
holoviews.notebook_extension("matplotlib")
1414

@@ -19,7 +19,7 @@ def ring(xy):
1919

2020
x, y = xy
2121
a = 0.2
22-
return x + np.exp(-(x ** 2 + y ** 2 - 0.75 ** 2) ** 2 / a ** 4)
22+
return x + np.exp(-((x ** 2 + y ** 2 - 0.75 ** 2) ** 2) / a ** 4)
2323

2424
learner = adaptive.Learner2D(ring, bounds=[(-1, 1), (-1, 1)])
2525
adaptive.runner.simple(learner, goal=lambda l: l.loss() < 0.01)

docs/source/conf.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
#
32
# Configuration file for the Sphinx documentation builder.
43
#
@@ -18,12 +17,11 @@
1817
package_path = os.path.abspath("../..")
1918
# Insert into sys.path so that we can import adaptive here
2019
sys.path.insert(0, package_path)
21-
22-
import adaptive # noqa: E402
23-
2420
# Insert into PYTHONPATH so that jupyter-sphinx will pick it up
2521
os.environ["PYTHONPATH"] = ":".join((package_path, os.environ.get("PYTHONPATH", "")))
2622

23+
import adaptive # noqa: E402, isort:skip
24+
2725
# -- Project information -----------------------------------------------------
2826

2927
project = "adaptive"

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32

43
import sys
54

0 commit comments

Comments
 (0)