Power up pre-commit
Joseph Weston authored on 12/12/2019 15:24:24 • GitHub committed on 12/12/2019 15:24:24... | ... |
@@ -1,16 +1,43 @@ |
1 | 1 |
repos: |
2 |
-- repo: https://github.com/ambv/black |
|
3 |
- rev: 19.3b0 |
|
4 |
- hooks: |
|
5 |
- - id: black |
|
6 |
- language_version: python3.7 |
|
7 | 2 |
- repo: https://github.com/pre-commit/pre-commit-hooks |
8 |
- rev: v2.1.0 |
|
3 |
+ rev: v2.4.0 |
|
9 | 4 |
hooks: |
10 |
- - id: end-of-file-fixer |
|
11 | 5 |
- id: trailing-whitespace |
6 |
+ - id: end-of-file-fixer |
|
7 |
+ - id: check-docstring-first |
|
8 |
+ - id: check-yaml |
|
9 |
+ - id: debug-statements |
|
10 |
+ - id: check-ast |
|
12 | 11 |
- repo: https://gitlab.com/pycqa/flake8 |
13 |
- rev: 3.7.8 |
|
12 |
+ rev: 3.7.9 |
|
14 | 13 |
hooks: |
15 | 14 |
- id: flake8 |
16 |
- args: ['--max-line-length=500', '--ignore=E203,E266,E501,W503', '--max-complexity=18', '--select=B,C,E,F,W,T4,B9'] |
|
15 |
+ args: |
|
16 |
+ - --max-line-length=500 |
|
17 |
+ - --ignore=E203,E266,E501,W503 |
|
18 |
+ - --max-complexity=18 |
|
19 |
+ - --select=B,C,E,F,W,T4,B9 |
|
20 |
+- repo: https://github.com/ambv/black |
|
21 |
+ rev: 19.10b0 |
|
22 |
+ hooks: |
|
23 |
+ - id: black |
|
24 |
+ language_version: python3.7 |
|
25 |
+- repo: https://github.com/asottile/pyupgrade |
|
26 |
+ rev: v1.25.2 |
|
27 |
+ hooks: |
|
28 |
+ - id: pyupgrade |
|
29 |
+ args: ['--py36-plus'] |
|
30 |
+- repo: https://github.com/pre-commit/mirrors-isort |
|
31 |
+ rev: v4.3.21 |
|
32 |
+ hooks: |
|
33 |
+ - id: isort |
|
34 |
+ args: |
|
35 |
+ - --multi-line=3 |
|
36 |
+ - --trailing-comma |
|
37 |
+ - --force-grid-wrap=0 |
|
38 |
+ - --use-parentheses |
|
39 |
+ - --line-width=88 |
|
40 |
+- repo: https://github.com/asottile/seed-isort-config |
|
41 |
+ rev: v1.9.3 |
|
42 |
+ hooks: |
|
43 |
+ - id: seed-isort-config |
... | ... |
@@ -1,10 +1,8 @@ |
1 |
-# -*- coding: utf-8 -*- |
|
2 |
- |
|
3 | 1 |
import abc |
4 | 2 |
from contextlib import suppress |
5 | 3 |
from copy import deepcopy |
6 | 4 |
|
7 |
-from adaptive.utils import load, save, _RequireAttrsABCMeta |
|
5 |
+from adaptive.utils import _RequireAttrsABCMeta, load, save |
|
8 | 6 |
|
9 | 7 |
|
10 | 8 |
def uses_nth_neighbors(n): |
... | ... |
@@ -1,4 +1,3 @@ |
1 |
-# -*- coding: utf-8 -*- |
|
2 | 1 |
# Based on an adaptive quadrature algorithm by Pedro Gonnet |
3 | 2 |
|
4 | 3 |
import sys |
... | ... |
@@ -572,9 +571,15 @@ class IntegratorLearner(BaseLearner): |
572 | 571 |
) |
573 | 572 |
|
574 | 573 |
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 |
|
578 | 583 |
|
579 | 584 |
# Add the pending_points to the _stack such that they are evaluated again |
580 | 585 |
for x in self.pending_points: |
... | ... |
@@ -1,5 +1,3 @@ |
1 |
-# -*- coding: utf-8 -*- |
|
2 |
- |
|
3 | 1 |
import functools |
4 | 2 |
import itertools |
5 | 3 |
import random |
... | ... |
@@ -340,8 +338,8 @@ class LearnerND(BaseLearner): |
340 | 338 |
self._min_value = None |
341 | 339 |
self._max_value = None |
342 | 340 |
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 |
+ ) |
|
345 | 343 |
self._recompute_losses_factor = 1.1 |
346 | 344 |
|
347 | 345 |
# create a private random number generator with fixed seed |
... | ... |
@@ -228,7 +228,7 @@ def simplex_volume_in_embedding(vertices) -> float: |
228 | 228 |
# Make matrix and find volume |
229 | 229 |
sq_dists_mat = scipy.spatial.distance.squareform(bordered) |
230 | 230 |
|
231 |
- coeff = -(-2) ** (num_verts - 1) * factorial(num_verts - 1) ** 2 |
|
231 |
+ coeff = -((-2) ** (num_verts - 1)) * factorial(num_verts - 1) ** 2 |
|
232 | 232 |
vol_square = fast_det(sq_dists_mat) / coeff |
233 | 233 |
|
234 | 234 |
if vol_square < 0: |
... | ... |
@@ -1,5 +1,3 @@ |
1 |
-# -*- coding: utf-8 -*- |
|
2 |
- |
|
3 | 1 |
import collections |
4 | 2 |
import functools as ft |
5 | 3 |
import inspect |
... | ... |
@@ -129,7 +127,7 @@ def linear_with_peak(x, d: uniform(-1, 1)): |
129 | 127 |
def ring_of_fire(xy, d: uniform(0.2, 1)): |
130 | 128 |
a = 0.2 |
131 | 129 |
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) |
|
133 | 131 |
|
134 | 132 |
|
135 | 133 |
@learn_with(LearnerND, bounds=((-1, 1), (-1, 1), (-1, 1))) |
... | ... |
@@ -137,7 +135,7 @@ def ring_of_fire(xy, d: uniform(0.2, 1)): |
137 | 135 |
def sphere_of_fire(xyz, d: uniform(0.2, 1)): |
138 | 136 |
a = 0.2 |
139 | 137 |
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 |
|
141 | 139 |
|
142 | 140 |
|
143 | 141 |
@learn_with(SequenceLearner, sequence=range(1000)) |
... | ... |
@@ -12,7 +12,7 @@ def ring_of_fire(xy): |
12 | 12 |
a = 0.2 |
13 | 13 |
d = 0.7 |
14 | 14 |
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) |
|
16 | 16 |
|
17 | 17 |
|
18 | 18 |
def test_learnerND_inits_loss_depends_on_neighbors_correctly(): |
... | ... |
@@ -11,7 +11,7 @@ from adaptive.runner import simple as SimpleRunner |
11 | 11 |
def ring_of_fire(xy, d=0.75): |
12 | 12 |
a = 0.2 |
13 | 13 |
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) |
|
15 | 15 |
|
16 | 16 |
|
17 | 17 |
def test_learnerND_runs_to_10_points(): |
... | ... |
@@ -8,7 +8,7 @@ from PIL import Image, ImageDraw |
8 | 8 |
|
9 | 9 |
sys.path.insert(0, os.path.abspath("..")) # to get adaptive on the path |
10 | 10 |
|
11 |
-import adaptive # noqa: E402 |
|
11 |
+import adaptive # noqa: E402, isort:skip |
|
12 | 12 |
|
13 | 13 |
holoviews.notebook_extension("matplotlib") |
14 | 14 |
|
... | ... |
@@ -19,7 +19,7 @@ def create_and_run_learner(): |
19 | 19 |
|
20 | 20 |
x, y = xy |
21 | 21 |
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) |
|
23 | 23 |
|
24 | 24 |
learner = adaptive.Learner2D(ring, bounds=[(-1, 1), (-1, 1)]) |
25 | 25 |
adaptive.runner.simple(learner, goal=lambda l: l.loss() < 0.01) |
... | ... |
@@ -1,4 +1,3 @@ |
1 |
-# -*- coding: utf-8 -*- |
|
2 | 1 |
# |
3 | 2 |
# Configuration file for the Sphinx documentation builder. |
4 | 3 |
# |
... | ... |
@@ -18,12 +17,11 @@ import sys |
18 | 17 |
package_path = os.path.abspath("../..") |
19 | 18 |
# Insert into sys.path so that we can import adaptive here |
20 | 19 |
sys.path.insert(0, package_path) |
21 |
- |
|
22 |
-import adaptive # noqa: E402 |
|
23 |
- |
|
24 | 20 |
# Insert into PYTHONPATH so that jupyter-sphinx will pick it up |
25 | 21 |
os.environ["PYTHONPATH"] = ":".join((package_path, os.environ.get("PYTHONPATH", ""))) |
26 | 22 |
|
23 |
+import adaptive # noqa: E402, isort:skip |
|
24 |
+ |
|
27 | 25 |
# -- Project information ----------------------------------------------------- |
28 | 26 |
|
29 | 27 |
project = "adaptive" |