Skip to content

Commit f2abbcb

Browse files
committed
Run black on package
Black is an autoformatter that has ensures that the formatted code adheres to some strict guidelines. The formatted code should pass pylint and flake8, so it will be an easy way to ensure consistent formatting without having to deal with trial and error corrections to linters.
1 parent 5a2951b commit f2abbcb

File tree

96 files changed

+6482
-3927
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+6482
-3927
lines changed

docs/conf.py

+51-46
Original file line numberDiff line numberDiff line change
@@ -7,58 +7,58 @@
77
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
88
# ones.
99
extensions = [
10-
'sphinx.ext.autodoc',
11-
'sphinx.ext.doctest',
12-
'sphinx.ext.todo',
13-
'sphinx.ext.napoleon',
14-
'sphinx.ext.mathjax',
15-
'sphinx.ext.coverage',
16-
'sphinx.ext.viewcode',
17-
'sphinx.ext.autosummary',
18-
'sphinxcontrib.bibtex',
10+
"sphinx.ext.autodoc",
11+
"sphinx.ext.doctest",
12+
"sphinx.ext.todo",
13+
"sphinx.ext.napoleon",
14+
"sphinx.ext.mathjax",
15+
"sphinx.ext.coverage",
16+
"sphinx.ext.viewcode",
17+
"sphinx.ext.autosummary",
18+
"sphinxcontrib.bibtex",
1919
]
2020

2121
# Add any paths that contain templates here, relative to this directory.
22-
templates_path = ['_templates']
22+
templates_path = ["_templates"]
2323

2424

2525
mathjax_path = "https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
2626

2727
sphinx_gallery_conf = {
2828
# path to examples scripts
29-
'examples_dirs': '../examples',
29+
"examples_dirs": "../examples",
3030
# path where to save the generated examples
31-
'gallery_dirs': 'auto_examples',
31+
"gallery_dirs": "auto_examples",
3232
# path to the default thumb pics
3333
# 'default_thumb_file': './_static/wfns_white_bg_logo.png',
3434
# set the plot file pattern
35-
'filename_pattern': '/(plot_.*|.*_plot.py$)',
35+
"filename_pattern": "/(plot_.*|.*_plot.py$)",
3636
}
3737

3838
# The suffix(es) of source filenames.
3939
# You can specify multiple suffix as a list of string:
4040
# source_suffix = ['.rst', '.md']
41-
source_suffix = '.rst'
41+
source_suffix = ".rst"
4242

4343
# The encoding of source files.
4444
# source_encoding = 'utf-8-sig'
4545

4646
# The master toctree document.
47-
master_doc = 'index'
47+
master_doc = "index"
4848

4949
# General information about the project.
50-
project = u'wfns'
51-
copyright = u'2017, Ayers\' Group @ McMaster University'
52-
author = u'Ayers\' Group @ McMaster University'
50+
project = u"wfns"
51+
copyright = u"2017, Ayers' Group @ McMaster University"
52+
author = u"Ayers' Group @ McMaster University"
5353

5454
# The version info for the project you're documenting, acts as replacement for
5555
# |version| and |release|, also used in various other places throughout the
5656
# built documents.
5757
#
5858
# The short X.Y version.
59-
version = u'0.0.0'
59+
version = u"0.0.0"
6060
# The full version, including alpha/beta/rc tags.
61-
release = u'0.0'
61+
release = u"0.0"
6262

6363
# The language for content autogenerated by Sphinx. Refer to documentation
6464
# for a list of supported languages.
@@ -75,7 +75,7 @@
7575

7676
# List of patterns, relative to source directory, that match files and
7777
# directories to ignore when looking for source files.
78-
exclude_patterns = ['_build', '_themes/*', 'sphinxext']
78+
exclude_patterns = ["_build", "_themes/*", "sphinxext"]
7979

8080
# The reST default role (used for this markup: `text`) to use for all
8181
# documents.
@@ -93,7 +93,7 @@
9393
# show_authors = False
9494

9595
# The name of the Pygments (syntax highlighting) style to use.
96-
pygments_style = 'sphinx'
96+
pygments_style = "sphinx"
9797

9898
# A list of ignored prefixes for module index sorting.
9999
# modindex_common_prefix = []
@@ -108,8 +108,8 @@
108108

109109
# The theme to use for HTML and HTML Help pages. See the documentation for
110110
# a list of builtin themes.
111-
html_theme = 'sphinx_rtd_theme'
112-
html_theme_path = ["_themes/sphinx_rtd_theme/", ]
111+
html_theme = "sphinx_rtd_theme"
112+
html_theme_path = ["_themes/sphinx_rtd_theme/"]
113113
html_show_sourcelink = False
114114

115115
# Theme options are theme-specific and customize the look and feel of a theme
@@ -134,12 +134,12 @@
134134
# The name of an image file (within the static path) to use as favicon of the
135135
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
136136
# pixels large.
137-
html_favicon = '_static/wfns_favicon.ico'
137+
html_favicon = "_static/wfns_favicon.ico"
138138

139139
# Add any paths that contain custom static files (such as style sheets) here,
140140
# relative to this directory. They are copied after the builtin static files,
141141
# so a file named "default.css" will overwrite the builtin "default.css".
142-
html_static_path = ['_static']
142+
html_static_path = ["_static"]
143143

144144
# Add any extra paths that contain custom files (such as robots.txt or
145145
# .htaccess) here, relative to this directory. These files are copied
@@ -202,30 +202,27 @@
202202
# html_search_scorer = 'scorer.js'
203203

204204
# Output file base name for HTML help builder.
205-
htmlhelp_basename = 'wfnsdoc'
205+
htmlhelp_basename = "wfnsdoc"
206206

207207
# -- imgmath for equation generation --------------------------------------
208208

209209
# imgmath_latex_preamble = r'''\usepackage{physics}'''
210210

211211
# -- Options for LaTeX output ---------------------------------------------
212212

213-
latex_engine = 'pdflatex'
213+
latex_engine = "pdflatex"
214214

215215
latex_elements = {
216216
# The paper size ('letterpaper' or 'a4paper').
217-
'papersize': 'letterpaper',
218-
217+
"papersize": "letterpaper",
219218
# The font size ('10pt', '11pt' or '12pt').
220219
# 'pointsize': '10pt',
221-
222220
# Additional stuff for the LaTeX preamble.
223-
'preamble': r'''
221+
"preamble": r"""
224222
\usepackage{amsmath}
225223
\usepackage{amsfont}
226224
\usepackage{braket}
227-
''',
228-
225+
""",
229226
# Latex figure (float) alignment
230227
# 'figure_align': 'htbp',
231228
}
@@ -234,8 +231,13 @@
234231
# (source start file, target name, title,
235232
# author, documentclass [howto, manual, or own class]).
236233
latex_documents = [
237-
(master_doc, 'wfns.tex', u'Project Documentation',
238-
u'Ayers\' Group @ McMaster University', 'manual'),
234+
(
235+
master_doc,
236+
"wfns.tex",
237+
u"Project Documentation",
238+
u"Ayers' Group @ McMaster University",
239+
"manual",
240+
)
239241
]
240242

241243
# The name of an image file (relative to this directory) to place at the top of
@@ -263,10 +265,7 @@
263265

264266
# One entry per manual page. List of tuples
265267
# (source start file, name, description, authors, manual section).
266-
man_pages = [
267-
(master_doc, 'wfns', u'Project Documentation',
268-
[author], 1)
269-
]
268+
man_pages = [(master_doc, "wfns", u"Project Documentation", [author], 1)]
270269

271270
# If true, show URL addresses after external links.
272271
# man_show_urls = False
@@ -278,9 +277,15 @@
278277
# (source start file, target name, title, author,
279278
# dir menu entry, description, category)
280279
texinfo_documents = [
281-
(master_doc, 'wfns', u'Project Documentation',
282-
author, 'wfns', 'One line description of project.',
283-
'Miscellaneous'),
280+
(
281+
master_doc,
282+
"wfns",
283+
u"Project Documentation",
284+
author,
285+
"wfns",
286+
"One line description of project.",
287+
"Miscellaneous",
288+
)
284289
]
285290

286291
# Documents to append as an appendix to all manuals.
@@ -300,12 +305,12 @@
300305

301306
# Put class docstring and the __init__ docstring together in the documentation
302307
# for your class when you use the autoclass directive.
303-
autoclass_content = 'both'
308+
autoclass_content = "both"
304309

305-
autodoc_member_order = 'bysource'
310+
autodoc_member_order = "bysource"
306311
# autodoc_default_flags = ['members', 'undoc-members', 'inherited-members', 'show-inheritance']
307312

308313
# -----------------------------------------------------------------------------
309314
# Autosummary
310315
# -----------------------------------------------------------------------------
311-
autosummary_generate = ['tech_api.rst']
316+
autosummary_generate = ["tech_api.rst"]

scripts/horton_gaussian_fchk.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def gaussian_fchk(fchk_file, horton_internal=False):
4444

4545
# for spin orbitals
4646
exps = [mol.exp_alpha]
47-
if hasattr(mol, 'exp_beta'):
47+
if hasattr(mol, "exp_beta"):
4848
exps.append(mol.exp_beta)
4949

5050
obasis = mol.obasis
@@ -64,10 +64,10 @@ def gaussian_fchk(fchk_file, horton_internal=False):
6464
for i, exp_i in enumerate(exps):
6565
for j, exp_j in enumerate(exps[i:]):
6666
j += i
67-
temp = np.einsum('sd,pqrs->pqrd', exp_j.coeffs, two_ab, casting='no', order='C')
68-
temp = np.einsum('rc,pqrd->pqcd', exp_i.coeffs, temp, casting='no', order='C')
69-
temp = np.einsum('qb,pqcd->pbcd', exp_j.coeffs, temp, casting='no', order='C')
70-
temp = np.einsum('pa,pbcd->abcd', exp_i.coeffs, temp, casting='no', order='C')
67+
temp = np.einsum("sd,pqrs->pqrd", exp_j.coeffs, two_ab, casting="no", order="C")
68+
temp = np.einsum("rc,pqrd->pqcd", exp_i.coeffs, temp, casting="no", order="C")
69+
temp = np.einsum("qb,pqcd->pbcd", exp_j.coeffs, temp, casting="no", order="C")
70+
temp = np.einsum("pa,pbcd->abcd", exp_i.coeffs, temp, casting="no", order="C")
7171
two_mo.append(temp)
7272
one_mo.append(exp_i.coeffs.T.dot(one_ab).dot(exp_i.coeffs))
7373

@@ -78,8 +78,9 @@ def gaussian_fchk(fchk_file, horton_internal=False):
7878
"two_int": tuple(two_mo),
7979
}
8080
if horton_internal:
81-
raise NotImplementedError('horton_internal storage is unsupported until it become Python '
82-
'3.6 compatible.')
81+
raise NotImplementedError(
82+
"horton_internal storage is unsupported until it become Python " "3.6 compatible."
83+
)
8384
# output["horton_internal"] = {
8485
# "mol": mol,
8586
# "lf": mol.lf,
@@ -90,20 +91,20 @@ def gaussian_fchk(fchk_file, horton_internal=False):
9091
return output
9192

9293

93-
if __name__ == '__main__':
94+
if __name__ == "__main__":
9495
# extract keyword from command line
9596
kwargs = {key: val for key, val in zip(sys.argv[4::2], sys.argv[5::2])}
9697
# change data types
97-
if 'horton_internal' in kwargs:
98-
kwargs['horton_internal'] = (kwargs['horton_internal'] == 'True')
98+
if "horton_internal" in kwargs:
99+
kwargs["horton_internal"] = kwargs["horton_internal"] == "True"
99100

100101
data = gaussian_fchk(**kwargs)
101-
np.save(sys.argv[1], [data['el_energy'], data['nuc_nuc_energy']])
102-
if len(data['one_int']) == 1:
103-
np.save(sys.argv[2], data['one_int'][0])
102+
np.save(sys.argv[1], [data["el_energy"], data["nuc_nuc_energy"]])
103+
if len(data["one_int"]) == 1:
104+
np.save(sys.argv[2], data["one_int"][0])
104105
else:
105-
np.save(sys.argv[2], data['one_int'])
106-
if len(data['two_int']) == 1:
107-
np.save(sys.argv[3], data['two_int'][0])
106+
np.save(sys.argv[2], data["one_int"])
107+
if len(data["two_int"]) == 1:
108+
np.save(sys.argv[3], data["two_int"][0])
108109
else:
109-
np.save(sys.argv[3], data['two_int'])
110+
np.save(sys.argv[3], data["two_int"])

scripts/horton_hartreefock.py

+47-29
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,32 @@
88
"""
99
import sys
1010
import numpy as np
11-
from horton import (IOData, get_gobasis,
12-
PlainSCFSolver, EDIIS2SCFSolver,
13-
DenseLinalgFactory,
14-
compute_nucnuc, guess_core_hamiltonian, transform_integrals,
15-
AufbauOccModel, RTwoIndexTerm, RDirectTerm, RExchangeTerm, REffHam)
16-
17-
18-
def hartreefock(fn=None, basis=None, nelec=None, solver=EDIIS2SCFSolver, tol=1.0e-12,
19-
horton_internal=False, **kwargs):
11+
from horton import (
12+
IOData,
13+
get_gobasis,
14+
PlainSCFSolver,
15+
EDIIS2SCFSolver,
16+
DenseLinalgFactory,
17+
compute_nucnuc,
18+
guess_core_hamiltonian,
19+
transform_integrals,
20+
AufbauOccModel,
21+
RTwoIndexTerm,
22+
RDirectTerm,
23+
RExchangeTerm,
24+
REffHam,
25+
)
26+
27+
28+
def hartreefock(
29+
fn=None,
30+
basis=None,
31+
nelec=None,
32+
solver=EDIIS2SCFSolver,
33+
tol=1.0e-12,
34+
horton_internal=False,
35+
**kwargs
36+
):
2037
"""Run a HF calculation using HORTON.
2138
2239
Parameters
@@ -101,7 +118,7 @@ def hartreefock(fn=None, basis=None, nelec=None, solver=EDIIS2SCFSolver, tol=1.0
101118
ham.compute_fock(fock_alpha)
102119
orb.from_fock_and_dm(fock_alpha, dm, olp)
103120
else:
104-
raise ValueError('Given solver, {0}, is not callable'.format(solver))
121+
raise ValueError("Given solver, {0}, is not callable".format(solver))
105122
energy = ham.cache["energy"]
106123

107124
# Transform one- and two- electron integrals into MO basis
@@ -125,35 +142,36 @@ def hartreefock(fn=None, basis=None, nelec=None, solver=EDIIS2SCFSolver, tol=1.0
125142
"occ_model": occ_model,
126143
"one": one,
127144
"two": two,
128-
"orb": [orb, ],
145+
"orb": [orb],
129146
"olp": olp,
130147
}
131-
raise NotImplementedError('horton_internal storage is unsupported until it become Python '
132-
'3.6 compatible.')
148+
raise NotImplementedError(
149+
"horton_internal storage is unsupported until it become Python " "3.6 compatible."
150+
)
133151

134152
return output
135153

136154

137-
if __name__ == '__main__':
155+
if __name__ == "__main__":
138156
# extract keyword from command line
139157
kwargs = {key: val for key, val in zip(sys.argv[4::2], sys.argv[5::2])}
140158
# change data types
141-
if 'nelec' in kwargs:
142-
kwargs['nelec'] = int(kwargs['nelec'])
143-
if 'tol' in kwargs:
144-
kwargs['tol'] = float(kwargs['tol'])
145-
if 'horton_internal' in kwargs:
146-
kwargs['horton_internal'] = bool(kwargs['horton_internal'])
147-
if 'solver' in kwargs:
148-
kwargs['solver'] = locals()[kwargs['solver']]
159+
if "nelec" in kwargs:
160+
kwargs["nelec"] = int(kwargs["nelec"])
161+
if "tol" in kwargs:
162+
kwargs["tol"] = float(kwargs["tol"])
163+
if "horton_internal" in kwargs:
164+
kwargs["horton_internal"] = bool(kwargs["horton_internal"])
165+
if "solver" in kwargs:
166+
kwargs["solver"] = locals()[kwargs["solver"]]
149167

150168
data = hartreefock(**kwargs)
151-
np.save(sys.argv[1], [data['el_energy'], data['nuc_nuc_energy']])
152-
if len(data['one_int']) == 1:
153-
np.save(sys.argv[2], data['one_int'][0])
169+
np.save(sys.argv[1], [data["el_energy"], data["nuc_nuc_energy"]])
170+
if len(data["one_int"]) == 1:
171+
np.save(sys.argv[2], data["one_int"][0])
154172
else:
155-
np.save(sys.argv[2], data['one_int'])
156-
if len(data['two_int']) == 1:
157-
np.save(sys.argv[3], data['two_int'][0])
173+
np.save(sys.argv[2], data["one_int"])
174+
if len(data["two_int"]) == 1:
175+
np.save(sys.argv[3], data["two_int"][0])
158176
else:
159-
np.save(sys.argv[3], data['two_int'])
177+
np.save(sys.argv[3], data["two_int"])

0 commit comments

Comments
 (0)