Skip to content

Commit 176c745

Browse files
committed
fix import order and style
1 parent 68500f1 commit 176c745

30 files changed

+91
-99
lines changed

adaptive/__init__.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,19 @@
22

33
from contextlib import suppress
44

5-
from adaptive.notebook_integration import (notebook_extension, live_plot,
6-
active_plotting_tasks)
7-
8-
from adaptive import learner
9-
from adaptive import runner
10-
from adaptive import utils
11-
12-
from adaptive.learner import (
13-
BaseLearner, Learner1D, Learner2D, LearnerND,
14-
AverageLearner, BalancingLearner, make_datasaver,
15-
DataSaver, IntegratorLearner
16-
)
5+
from adaptive import learner, runner, utils
6+
from adaptive._version import __version__
7+
from adaptive.learner import (AverageLearner, BalancingLearner, BaseLearner,
8+
DataSaver, IntegratorLearner, Learner1D,
9+
Learner2D, LearnerND, make_datasaver)
10+
from adaptive.notebook_integration import (active_plotting_tasks, live_plot,
11+
notebook_extension)
12+
from adaptive.runner import AsyncRunner, BlockingRunner, Runner
1713

1814
with suppress(ImportError):
1915
# Only available if 'scikit-optimize' is installed
2016
from adaptive.learner import SKOptLearner
2117

22-
from adaptive.runner import Runner, AsyncRunner, BlockingRunner
2318

24-
from adaptive._version import __version__
2519
del _version
26-
2720
del notebook_integration # to avoid confusion with `notebook_extension`

adaptive/_version.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22
# This file is part of 'miniver': https://github.com/jbweston/miniver
33
#
4-
from collections import namedtuple
54
import os
65
import subprocess
7-
6+
from collections import namedtuple
87
from distutils.command.build_py import build_py as build_py_orig
8+
99
from setuptools.command.sdist import sdist as sdist_orig
1010

1111
Version = namedtuple('Version', ('release', 'dev', 'labels'))
@@ -53,7 +53,7 @@ def pep440_format(version_info):
5353
if release.endswith('-dev') or release.endswith('.dev'):
5454
version_parts.append(dev)
5555
else: # prefer PEP440 over strict adhesion to semver
56-
version_parts.append('.dev{}'.format(dev))
56+
version_parts.append(f'.dev{dev}')
5757

5858
if labels:
5959
version_parts.append('+')
@@ -146,13 +146,13 @@ def get_version_from_git_archive(version_info):
146146
return None
147147

148148
VTAG = 'tag: v'
149-
refs = set(r.strip() for r in refnames.split(","))
150-
version_tags = set(r[len(VTAG):] for r in refs if r.startswith(VTAG))
149+
refs = {r.strip() for r in refnames.split(",")}
150+
version_tags = {r[len(VTAG):] for r in refs if r.startswith(VTAG)}
151151
if version_tags:
152152
release, *_ = sorted(version_tags) # prefer e.g. "2.0" over "2.0rc1"
153153
return Version(release, dev=None, labels=None)
154154
else:
155-
return Version('unknown', dev=None, labels=['g{}'.format(git_hash)])
155+
return Version('unknown', dev=None, labels=[f'g{git_hash}'])
156156

157157

158158
__version__ = get_version()

adaptive/learner/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from contextlib import suppress
44

55
from adaptive.learner.average_learner import AverageLearner
6-
from adaptive.learner.base_learner import BaseLearner
76
from adaptive.learner.balancing_learner import BalancingLearner
7+
from adaptive.learner.base_learner import BaseLearner
8+
from adaptive.learner.data_saver import DataSaver, make_datasaver
9+
from adaptive.learner.integrator_learner import IntegratorLearner
810
from adaptive.learner.learner1D import Learner1D
911
from adaptive.learner.learner2D import Learner2D
1012
from adaptive.learner.learnerND import LearnerND
11-
from adaptive.learner.integrator_learner import IntegratorLearner
12-
from adaptive.learner.data_saver import DataSaver, make_datasaver
1313

1414
with suppress(ImportError):
1515
# Only available if 'scikit-optimize' is installed

adaptive/learner/balancing_learner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22

3+
import os.path
34
from collections import defaultdict
45
from collections.abc import Iterable
56
from contextlib import suppress
67
from functools import partial
78
from operator import itemgetter
8-
import os.path
99

1010
import numpy as np
1111

@@ -82,7 +82,7 @@ def __init__(self, learners, *, cdims=None, strategy='loss_improvements'):
8282
self._pending_loss = {}
8383
self._cdims_default = cdims
8484

85-
if len(set(learner.__class__ for learner in self.learners)) > 1:
85+
if len({learner.__class__ for learner in self.learners}) > 1:
8686
raise TypeError('A BalacingLearner can handle only one type'
8787
' of learners.')
8888

adaptive/learner/base_learner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from contextlib import suppress
55
from copy import deepcopy
66

7-
from adaptive.utils import save, load
7+
from adaptive.utils import load, save
88

99

1010
def uses_nth_neighbors(n):

adaptive/learner/data_saver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
from collections import OrderedDict
43
import functools
4+
from collections import OrderedDict
55

66
from adaptive.learner.base_learner import BaseLearner
77
from adaptive.utils import copy_docstring_from

adaptive/learner/integrator_coeffs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
# -*- coding: utf-8 -*-
22
# Based on an adaptive quadrature algorithm by Pedro Gonnet
33

4-
from fractions import Fraction
54
from collections import defaultdict
5+
from fractions import Fraction
6+
67
import numpy as np
78
import scipy.linalg
89

adaptive/learner/integrator_learner.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# -*- coding: utf-8 -*-
22
# Based on an adaptive quadrature algorithm by Pedro Gonnet
33

4+
import sys
45
from collections import defaultdict
56
from math import sqrt
67
from operator import attrgetter
7-
import sys
88

99
import numpy as np
1010
from scipy.linalg import norm
@@ -14,9 +14,8 @@
1414
from adaptive.notebook_integration import ensure_holoviews
1515
from adaptive.utils import cache_latest, restore
1616

17-
from .integrator_coeffs import (b_def, T_left, T_right, ns, hint,
18-
ndiv_max, min_sep, eps, xi, V_inv,
19-
Vcond, alpha, gamma)
17+
from .integrator_coeffs import (T_left, T_right, V_inv, Vcond, alpha, b_def,
18+
eps, gamma, hint, min_sep, ndiv_max, ns, xi)
2019

2120

2221
def _downdate(c, nans, depth):
@@ -298,10 +297,10 @@ def complete_process(self, depth):
298297

299298
def __repr__(self):
300299
lst = [
301-
'(a, b)=({:.5f}, {:.5f})'.format(self.a, self.b),
302-
'depth={}'.format(self.depth),
303-
'rdepth={}'.format(self.rdepth),
304-
'err={:.5E}'.format(self.err),
300+
f'(a, b)=({self.a:.5f}, {self.b:.5f})',
301+
f'depth={self.depth}',
302+
f'rdepth={self.rdepth}',
303+
f'err={self.err:.5E}',
305304
'igral={:.5E}'.format(self.igral if hasattr(self, 'igral') else np.inf),
306305
]
307306
return ' '.join(lst)

adaptive/learner/learner1D.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# -*- coding: utf-8 -*-
22

3-
from copy import deepcopy
43
import heapq
54
import itertools
65
import math
76
from collections.abc import Iterable
7+
from copy import deepcopy
88

99
import numpy as np
10-
import sortedcontainers
1110
import sortedcollections
11+
import sortedcontainers
1212

1313
from adaptive.learner.base_learner import BaseLearner, uses_nth_neighbors
1414
from adaptive.learner.learnerND import volume

adaptive/learner/learner2D.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- coding: utf-8 -*-
22

3+
import itertools
34
from collections import OrderedDict
45
from copy import copy
5-
import itertools
66
from math import sqrt
77

88
import numpy as np
@@ -12,7 +12,6 @@
1212
from adaptive.notebook_integration import ensure_holoviews
1313
from adaptive.utils import cache_latest
1414

15-
1615
# Learner2D and helper functions.
1716

1817
def deviations(ip):

0 commit comments

Comments
 (0)