Skip to content

Commit 54ebaa7

Browse files
author
Max Jones
authored
Use defaults for Black code formatting (#103)
1 parent a36a958 commit 54ebaa7

15 files changed

+339
-362
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,11 @@ repos:
1212
- id: check-json
1313
exclude: "asv_bench/asv.conf.json"
1414
- id: check-yaml
15-
- id: double-quote-string-fixer
1615

1716
- repo: https://github.com/psf/black
18-
rev: 22.8.0
17+
rev: 22.10.0
1918
hooks:
20-
- id: black
21-
args: ["--line-length", "80", "--skip-string-normalization"]
19+
- id: black-jupyter
2220

2321
- repo: https://github.com/PyCQA/flake8
2422
rev: 5.0.4
@@ -39,7 +37,7 @@ repos:
3937
- id: prettier
4038

4139
- repo: https://github.com/pre-commit/mirrors-mypy
42-
rev: v0.981
40+
rev: v0.982
4341
hooks:
4442
- id: mypy
4543
additional_dependencies: [

asv_bench/benchmarks/benchmarks.py

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,53 @@ def setup(self, *args, **kwargs):
1313
shape = (10, 50, 100)
1414
self.ds_3d = xr.Dataset(
1515
{
16-
'foo': (['time', 'y', 'x'], np.random.rand(*shape)),
16+
"foo": (["time", "y", "x"], np.random.rand(*shape)),
1717
},
1818
{
19-
'x': (['x'], np.arange(shape[-1])),
20-
'y': (['y'], np.arange(shape[-2])),
19+
"x": (["x"], np.arange(shape[-1])),
20+
"y": (["y"], np.arange(shape[-2])),
2121
},
2222
)
2323

2424
shape_4d = (10, 50, 100, 3)
2525
self.ds_4d = xr.Dataset(
2626
{
27-
'foo': (['time', 'y', 'x', 'b'], np.random.rand(*shape_4d)),
27+
"foo": (["time", "y", "x", "b"], np.random.rand(*shape_4d)),
2828
},
2929
{
30-
'x': (['x'], np.arange(shape_4d[-2])),
31-
'y': (['y'], np.arange(shape_4d[-3])),
32-
'b': (['b'], np.arange(shape_4d[-1])),
30+
"x": (["x"], np.arange(shape_4d[-2])),
31+
"y": (["y"], np.arange(shape_4d[-3])),
32+
"b": (["b"], np.arange(shape_4d[-1])),
3333
},
3434
)
3535

3636
self.ds_xy = xr.Dataset(
3737
{
38-
'x': (
39-
['sample', 'feature'],
38+
"x": (
39+
["sample", "feature"],
4040
np.random.random((shape[-1], shape[0])),
4141
),
42-
'y': (['sample'], np.random.random(shape[-1])),
42+
"y": (["sample"], np.random.random(shape[-1])),
4343
},
4444
)
4545

4646

4747
class Generator(Base):
48-
@parameterized(['preload_batch'], ([True, False]))
48+
@parameterized(["preload_batch"], ([True, False]))
4949
def time_batch_preload(self, preload_batch):
5050
"""
5151
Construct a generator on a chunked DataSet with and without preloading
5252
batches.
5353
"""
54-
ds_dask = self.ds_xy.chunk({'sample': 2})
55-
BatchGenerator(
56-
ds_dask, input_dims={'sample': 2}, preload_batch=preload_batch
57-
)
54+
ds_dask = self.ds_xy.chunk({"sample": 2})
55+
BatchGenerator(ds_dask, input_dims={"sample": 2}, preload_batch=preload_batch)
5856

5957
@parameterized(
60-
['input_dims', 'batch_dims', 'input_overlap'],
58+
["input_dims", "batch_dims", "input_overlap"],
6159
(
62-
[{'x': 5}, {'x': 10}, {'x': 5, 'y': 5}, {'x': 10, 'y': 5}],
63-
[{}, {'x': 20}, {'x': 30}],
64-
[{}, {'x': 1}, {'x': 2}],
60+
[{"x": 5}, {"x": 10}, {"x": 5, "y": 5}, {"x": 10, "y": 5}],
61+
[{}, {"x": 20}, {"x": 30}],
62+
[{}, {"x": 1}, {"x": 2}],
6563
),
6664
)
6765
def time_batch_input(self, input_dims, batch_dims, input_overlap):
@@ -76,8 +74,8 @@ def time_batch_input(self, input_dims, batch_dims, input_overlap):
7674
)
7775

7876
@parameterized(
79-
['input_dims', 'concat_input_dims'],
80-
([{'x': 5}, {'x': 10}, {'x': 5, 'y': 5}], [True, False]),
77+
["input_dims", "concat_input_dims"],
78+
([{"x": 5}, {"x": 10}, {"x": 5, "y": 5}], [True, False]),
8179
)
8280
def time_batch_concat(self, input_dims, concat_input_dims):
8381
"""
@@ -91,10 +89,10 @@ def time_batch_concat(self, input_dims, concat_input_dims):
9189
)
9290

9391
@parameterized(
94-
['input_dims', 'batch_dims', 'concat_input_dims'],
92+
["input_dims", "batch_dims", "concat_input_dims"],
9593
(
96-
[{'x': 5}, {'x': 5, 'y': 5}],
97-
[{}, {'x': 10}, {'x': 10, 'y': 10}],
94+
[{"x": 5}, {"x": 5, "y": 5}],
95+
[{}, {"x": 10}, {"x": 10, "y": 10}],
9896
[True, False],
9997
),
10098
)
@@ -113,8 +111,8 @@ def time_batch_concat_4d(self, input_dims, batch_dims, concat_input_dims):
113111

114112
class Accessor(Base):
115113
@parameterized(
116-
['input_dims'],
117-
([{'x': 2}, {'x': 4}, {'x': 2, 'y': 2}, {'x': 4, 'y': 2}]),
114+
["input_dims"],
115+
([{"x": 2}, {"x": 4}, {"x": 2, "y": 2}, {"x": 4, "y": 2}]),
118116
)
119117
def time_accessor_input_dim(self, input_dims):
120118
"""
@@ -127,8 +125,8 @@ def time_accessor_input_dim(self, input_dims):
127125
class TorchLoader(Base):
128126
def setup(self, *args, **kwargs):
129127
super().setup(**kwargs)
130-
self.x_gen = BatchGenerator(self.ds_xy['x'], {'sample': 10})
131-
self.y_gen = BatchGenerator(self.ds_xy['y'], {'sample': 10})
128+
self.x_gen = BatchGenerator(self.ds_xy["x"], {"sample": 10})
129+
self.y_gen = BatchGenerator(self.ds_xy["y"], {"sample": 10})
132130

133131
def time_map_dataset(self):
134132
"""

doc/conf.py

Lines changed: 51 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
# sys.path.insert(0, os.path.abspath('.'))
2727
# sys.path.insert(os.path.abspath('..'))
2828

29-
print('python exec:', sys.executable)
30-
print('sys.path:', sys.path)
31-
print('xbatcher.version:', xbatcher.__version__)
29+
print("python exec:", sys.executable)
30+
print("sys.path:", sys.path)
31+
print("xbatcher.version:", xbatcher.__version__)
3232

3333

3434
# -- General configuration ------------------------------------------------
@@ -40,68 +40,64 @@
4040
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4141
# ones.
4242
extensions = [
43-
'sphinx.ext.mathjax',
44-
'sphinx.ext.autodoc',
45-
'sphinx.ext.autosummary',
46-
'sphinx.ext.extlinks',
47-
'sphinx.ext.viewcode',
48-
'sphinx.ext.intersphinx',
49-
'numpydoc',
50-
'nbsphinx',
51-
'IPython.sphinxext.ipython_directive',
52-
'IPython.sphinxext.ipython_console_highlighting',
53-
'sphinx_autosummary_accessors',
54-
'sphinx_copybutton',
43+
"sphinx.ext.mathjax",
44+
"sphinx.ext.autodoc",
45+
"sphinx.ext.autosummary",
46+
"sphinx.ext.extlinks",
47+
"sphinx.ext.viewcode",
48+
"sphinx.ext.intersphinx",
49+
"numpydoc",
50+
"nbsphinx",
51+
"IPython.sphinxext.ipython_directive",
52+
"IPython.sphinxext.ipython_console_highlighting",
53+
"sphinx_autosummary_accessors",
54+
"sphinx_copybutton",
5555
]
5656

5757
# never execute notebooks: avoids lots of expensive imports on rtd
5858
# https://nbsphinx.readthedocs.io/en/0.2.14/never-execute.html
59-
nbsphinx_execute = 'never'
59+
nbsphinx_execute = "never"
6060

6161

6262
# http://stackoverflow.com/questions/5599254/how-to-use-sphinxs-autodoc-to-document-a-classs-init-self-method
6363
def skip(app, what, name, obj, skip, options):
64-
if name == '__init__':
64+
if name == "__init__":
6565
return False
6666
return skip
6767

6868

6969
def setup(app):
70-
app.connect('autodoc-skip-member', skip)
70+
app.connect("autodoc-skip-member", skip)
7171

7272

73-
autodoc_mock_imports = ['torch', 'tensorflow']
73+
autodoc_mock_imports = ["torch", "tensorflow"]
7474

7575
# link to github issues
76-
extlinks = {
77-
'issue': ('https://github.com/xarray-contrib/xbatcher/issues/%s', 'GH')
78-
}
76+
extlinks = {"issue": ("https://github.com/xarray-contrib/xbatcher/issues/%s", "GH")}
7977

8078
# sphinx-copybutton configurations (from https://github.com/pydata/xarray/blob/main/doc/conf.py)
81-
copybutton_prompt_text = (
82-
r'>>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: '
83-
)
79+
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "
8480
copybutton_prompt_is_regexp = True
8581

8682
autosummary_generate = True
8783
numpydoc_class_members_toctree = False
8884
numpydoc_show_class_members = False
8985

9086
# Add any paths that contain templates here, relative to this directory.
91-
templates_path = ['_templates', sphinx_autosummary_accessors.templates_path]
87+
templates_path = ["_templates", sphinx_autosummary_accessors.templates_path]
9288

9389
# The suffix of source filenames.
94-
source_suffix = '.rst'
90+
source_suffix = ".rst"
9591

9692
# The encoding of source files.
9793
# source_encoding = 'utf-8-sig'
9894

9995
# The master toctree document.
100-
master_doc = 'index'
96+
master_doc = "index"
10197

10298
# General information about the project.
103-
project = u'xbatcher'
104-
copyright = u'2021, xbatcher developers'
99+
project = "xbatcher"
100+
copyright = "2021, xbatcher developers"
105101

106102
# The version info for the project you're documenting, acts as replacement for
107103
# |version| and |release|, also used in various other places throughout the
@@ -124,7 +120,7 @@ def setup(app):
124120

125121
# List of patterns, relative to source directory, that match files and
126122
# directories to ignore when looking for source files.
127-
exclude_patterns = ['_build']
123+
exclude_patterns = ["_build"]
128124

129125
# The reST default role (used for this markup: `text`) to use for all
130126
# documents.
@@ -142,7 +138,7 @@ def setup(app):
142138
# show_authors = False
143139

144140
# The name of the Pygments (syntax highlighting) style to use.
145-
pygments_style = 'sphinx'
141+
pygments_style = "sphinx"
146142

147143
# A list of ignored prefixes for module index sorting.
148144
# modindex_common_prefix = []
@@ -156,15 +152,15 @@ def setup(app):
156152
# The theme to use for HTML and HTML Help pages. See the documentation for
157153
# a list of builtin themes.
158154
# tml_theme = 'default'
159-
html_theme = 'pangeo_sphinx_book_theme'
155+
html_theme = "pangeo_sphinx_book_theme"
160156

161157
# Theme options are theme-specific and customize the look and feel of a theme
162158
# further. For a list of options available for each theme, see the
163159
# documentation.
164160
html_theme_options = {
165-
'repository_url': 'https://github.com/xarray-contrib/xbatcher',
166-
'use_repository_button': True,
167-
'use_issues_button': True,
161+
"repository_url": "https://github.com/xarray-contrib/xbatcher",
162+
"use_repository_button": True,
163+
"use_issues_button": True,
168164
}
169165

170166
# Add any paths that contain custom themes here, relative to this directory.
@@ -238,7 +234,7 @@ def setup(app):
238234
# html_file_suffix = None
239235

240236
# Output file base name for HTML help builder.
241-
htmlhelp_basename = 'xbatcherdoc'
237+
htmlhelp_basename = "xbatcherdoc"
242238

243239

244240
# -- Options for LaTeX output ---------------------------------------------
@@ -257,11 +253,11 @@ def setup(app):
257253
# author, documentclass [howto, manual, or own class]).
258254
latex_documents = [
259255
(
260-
'index',
261-
'xbatcher.tex',
262-
u'xbatcher Documentation',
263-
u'xbatcher developers',
264-
'manual',
256+
"index",
257+
"xbatcher.tex",
258+
"xbatcher Documentation",
259+
"xbatcher developers",
260+
"manual",
265261
),
266262
]
267263

@@ -292,10 +288,10 @@ def setup(app):
292288
# (source start file, name, description, authors, manual section).
293289
man_pages = [
294290
(
295-
'index',
296-
'xbatcher',
297-
u'xbatcher Documentation',
298-
[u'xbatcher developers'],
291+
"index",
292+
"xbatcher",
293+
"xbatcher Documentation",
294+
["xbatcher developers"],
299295
1,
300296
)
301297
]
@@ -311,13 +307,13 @@ def setup(app):
311307
# dir menu entry, description, category)
312308
texinfo_documents = [
313309
(
314-
'index',
315-
'xbatcher',
316-
u'xbatcher Documentation',
317-
u'xbatcher developers',
318-
'xbatcher',
319-
'One line description of project.',
320-
'Miscellaneous',
310+
"index",
311+
"xbatcher",
312+
"xbatcher Documentation",
313+
"xbatcher developers",
314+
"xbatcher",
315+
"One line description of project.",
316+
"Miscellaneous",
321317
),
322318
]
323319

@@ -336,6 +332,6 @@ def setup(app):
336332

337333
# Example configuration for intersphinx: refer to the Python standard library.
338334
intersphinx_mapping = {
339-
'python': ('https://docs.python.org/3/', None),
340-
'xarray': ('http://xarray.pydata.org/en/stable/', None),
335+
"python": ("https://docs.python.org/3/", None),
336+
"xarray": ("http://xarray.pydata.org/en/stable/", None),
341337
}

0 commit comments

Comments
 (0)