Skip to content

Commit a88f751

Browse files
authored
fixes from pre-commit (#9)
1 parent d8e47e6 commit a88f751

File tree

11 files changed

+113
-85
lines changed

11 files changed

+113
-85
lines changed

.github/workflows/pull_request.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
check_formatting:
2525
uses: NWChemEx/.github/.github/workflows/check_formatting.yaml@master
2626
with:
27-
license_config: ".github/.licenserc.yaml"
27+
license_config: ".licenserc.yaml"
2828
cpp_source_dirs: ""
2929

3030
# test_nwx_docs:
@@ -36,4 +36,3 @@ jobs:
3636
uses: NWChemEx/.github/.github/workflows/test_nwx_library.yaml@master
3737
with:
3838
compilers: '["gcc-11", "clang-14"]'
39-
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@ header:
2222
- LICENSE
2323
- version.txt
2424
- docs/source/nitpick_exceptions
25+
- build/
2526

2627
comment: never

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sphinx==v7.2.6
2+
sphinx-autoapi
23
sphinx_rtd_theme==1.3.0
3-
sphinxcontrib-bibtex
44
sphinx_tabs
5-
sphinx-autoapi
5+
sphinxcontrib-bibtex

docs/source/conf.py

Lines changed: 47 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,33 @@
2121
# http://www.sphinx-doc.org/en/master/config
2222

2323
import os
24-
import sys
2524

2625
# -- Project information -----------------------------------------------------
2726

28-
project = u'StructureFinder'
29-
copyright = u'2024, NWChemEx Community'
30-
author = u'NWChemEx Community'
27+
project = "StructureFinder"
28+
copyright = "2024, NWChemEx Community"
29+
author = "NWChemEx Community"
3130

3231
# Get the version from version.txt
33-
version = '1.0.0'
32+
version = "1.0.0"
3433
# The full version, including alpha/beta/rc tags
3534
release = version
3635

3736
# -- General configuration ---------------------------------------------------
3837

3938
# We use numref which is introduced in Sphinx 1.3
40-
needs_sphinx = '1.3'
39+
needs_sphinx = "1.3"
4140

4241
# Add any Sphinx extension module names here, as strings. They can be
4342
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4443
# ones.
4544
extensions = [
46-
'sphinx.ext.doctest', 'sphinx.ext.todo', 'sphinx.ext.coverage',
47-
'sphinx.ext.mathjax', 'sphinx.ext.githubpages', 'autoapi.extension'
45+
"sphinx.ext.doctest",
46+
"sphinx.ext.todo",
47+
"sphinx.ext.coverage",
48+
"sphinx.ext.mathjax",
49+
"sphinx.ext.githubpages",
50+
"autoapi.extension",
4851
]
4952
dir_path = os.path.dirname(os.path.realpath(__file__))
5053
doc_path = os.path.dirname(dir_path)
@@ -57,25 +60,25 @@
5760
# You can specify multiple suffix as a list of string:
5861
#
5962
# source_suffix = ['.rst', '.md']
60-
source_suffix = '.rst'
63+
source_suffix = ".rst"
6164

6265
# The master toctree document.
63-
master_doc = 'index'
66+
master_doc = "index"
6467

6568
# The language for content autogenerated by Sphinx. Refer to documentation
6669
# for a list of supported languages.
6770
#
6871
# This is also used if you do content translation via gettext catalogs.
6972
# Usually you set "language" from the command line for these cases.
70-
language = 'en'
73+
language = "en"
7174

7275
# List of patterns, relative to source directory, that match files and
7376
# directories to ignore when looking for source files.
7477
# This pattern also affects html_static_path and html_extra_path .
7578
exclude_patterns = []
7679

7780
# The name of the Pygments (syntax highlighting) style to use.
78-
pygments_style = 'sphinx'
81+
pygments_style = "sphinx"
7982

8083
# Should figures be numbered?
8184
numfig = True
@@ -85,7 +88,7 @@
8588
# The theme to use for HTML and HTML Help pages. See the documentation for
8689
# a list of builtin themes.
8790
#
88-
html_theme = 'sphinx_rtd_theme'
91+
html_theme = "sphinx_rtd_theme"
8992

9093
# Theme options are theme-specific and customize the look and feel of a theme
9194
# further. For a list of options available for each theme, see the
@@ -111,23 +114,20 @@
111114
# -- Options for HTMLHelp output ---------------------------------------------
112115

113116
# Output file base name for HTML help builder.
114-
htmlhelp_basename = project + 'doc'
117+
htmlhelp_basename = project + "doc"
115118

116119
# -- Options for LaTeX output ------------------------------------------------
117120

118121
latex_elements = {
119122
# The paper size ('letterpaper' or 'a4paper').
120123
#
121124
# 'papersize': 'letterpaper',
122-
123125
# The font size ('10pt', '11pt' or '12pt').
124126
#
125127
# 'pointsize': '10pt',
126-
127128
# Additional stuff for the LaTeX preamble.
128129
#
129130
# 'preamble': '',
130-
131131
# Latex figure (float) alignment
132132
#
133133
# 'figure_align': 'htbp',
@@ -137,49 +137,62 @@
137137
# (source start file, target name, title,
138138
# author, documentclass [howto, manual, or own class]).
139139
latex_documents = [
140-
(master_doc, project + '.tex', project + ' Documentation', author,
141-
'manual'),
140+
(
141+
master_doc,
142+
project + ".tex",
143+
project + " Documentation",
144+
author,
145+
"manual",
146+
),
142147
]
143148

144149
# -- Options for manual page output ------------------------------------------
145150

146151
# One entry per manual page. List of tuples
147152
# (source start file, name, description, authors, manual section).
148-
man_pages = [(master_doc, project.lower(), project + ' Documentation',
149-
[author], 1)]
153+
man_pages = [
154+
(master_doc, project.lower(), project + " Documentation", [author], 1)
155+
]
150156

151157
# -- Options for Texinfo output ----------------------------------------------
152158

153159
# Grouping the document tree into Texinfo files. List of tuples
154160
# (source start file, target name, title, author,
155161
# dir menu entry, description, category)
156162
texinfo_documents = [
157-
(master_doc, project, project + ' Documentation', author, project,
158-
'One line description of project.', 'Miscellaneous'),
163+
(
164+
master_doc,
165+
project,
166+
project + " Documentation",
167+
author,
168+
project,
169+
"One line description of project.",
170+
"Miscellaneous",
171+
),
159172
]
160173

161174
# -- Extension configuration -------------------------------------------------
162175
autoapi_dirs = [
163-
'../../src',
176+
"../../src",
164177
# '../../tests',
165178
]
166179
autoapi_add_toctree_entry = False
167180
autoapi_options = [
168-
'members',
169-
'undoc-members',
170-
'private-members',
171-
'show-inheritance',
172-
'show-module-summary',
173-
'special-members',
181+
"members",
182+
"undoc-members",
183+
"private-members",
184+
"show-inheritance",
185+
"show-module-summary",
186+
"special-members",
174187
# 'imported-members',
175188
]
176189

177190

178191
# This skips classes that derived from ModuleBase, because those classes will
179192
# have Module API documentation producable by PluginPlay
180193
def skip_pluginplay_modules(app, what, name, obj, skip, options):
181-
bases = obj.obj['bases'] if 'bases' in obj.obj.keys() else []
182-
if 'pluginplay.ModuleBase' in bases:
194+
bases = obj.obj["bases"] if "bases" in obj.obj.keys() else []
195+
if "pluginplay.ModuleBase" in bases:
183196
skip = True
184197
return skip
185198

@@ -191,7 +204,7 @@ def setup(sphinx):
191204
# -- Options for intersphinx extension ---------------------------------------
192205

193206
# Example configuration for intersphinx: refer to the Python standard library.
194-
intersphinx_mapping = {'https://docs.python.org/': None}
207+
intersphinx_mapping = {"https://docs.python.org/": None}
195208

196209
# -- Options for todo extension ----------------------------------------------
197210

@@ -203,7 +216,7 @@ def setup(sphinx):
203216
# Nitpick requires all references to be resolved
204217
# This will ignore those that references that can't be linked
205218
nitpick_ignore = []
206-
for line in open('nitpick_exceptions'):
219+
for line in open("nitpick_exceptions"):
207220
if line.strip() == "" or line.startswith("#"):
208221
continue
209222
dtype, target = line.split(None, 1)

src/python/structurefinder/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
from .lj_potential.lennard_jones_potential_module import (
16+
load_lennard_jones_potential,
17+
)
1518
from .pyberny import load_pyberny_modules
16-
from .lj_potential.lennard_jones_potential_module import load_lennard_jones_potential
1719

1820

1921
def load_modules(mm):

src/python/structurefinder/lj_potential/lennard_jones_potential_module.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
import numpy as np
1919
import pluginplay as pp
20-
from simde import TotalEnergy
2120
import tensorwrapper as tw
21+
from simde import TotalEnergy
2222

2323

2424
class LennardJonesPotential(pp.ModuleBase):
@@ -31,41 +31,41 @@ def __init__(self):
3131
self.description("Lennard-Jones 1D potential function")
3232
self.satisfies_property_type(TotalEnergy())
3333

34-
#--------------------------------------------------------------------------
34+
# --------------------------------------------------------------------------
3535

3636
# Module run_ member function ---------------------------------------------
3737
def run_(self, inputs, submods):
3838
"""
3939
Parameters
4040
----------
41-
inputs : Diatomic distance,
41+
inputs : Diatomic distance,
4242
TYPE ---> Float
43-
43+
4444
Returns
4545
-------
46-
E: Lennard-Jonnes 1D potential Energy,
47-
TYPE ---> Float
46+
E: Lennard-Jonnes 1D potential Energy,
47+
TYPE ---> Float
4848
"""
4949
pt = TotalEnergy()
50-
chem_sys, = pt.unwrap_inputs(inputs)
50+
(chem_sys,) = pt.unwrap_inputs(inputs)
5151
mol = chem_sys.molecule
5252
coor_0 = np.array([mol.at(0).x, mol.at(0).y, mol.at(0).z])
5353
coor_1 = np.array([mol.at(1).x, mol.at(1).y, mol.at(1).z])
54-
#----------------------------------------------------------------------
55-
assert (mol.size() == 2) #<--- To check molcule size contains 2-atoms
56-
#----------------------------------------------------------------------
54+
# ----------------------------------------------------------------------
55+
assert mol.size() == 2 # <--- To check molcule size contains 2-atoms
56+
# ----------------------------------------------------------------------
5757
r = np.linalg.norm(coor_0 - coor_1)
58-
#-------------- LENNARD-JONES FUNCTION --------------------------------
58+
# -------------- LENNARD-JONES FUNCTION --------------------------------
5959
E = 4 * ((1 / r**12) - (1 / r**6))
60-
#------------- ANALYTIC FORCE -----------------------------------------
61-
DE_x = -24 * ((2 / r**13) - (1 / r**7))
62-
FC = -DE_x
63-
#----------------------------------------------------------------------
60+
# ------------- ANALYTIC FORCE -----------------------------------------
61+
# DE_x = -24 * ((2 / r**13) - (1 / r**7))
62+
# FC = -DE_x
63+
# ----------------------------------------------------------------------
6464
E = tw.Tensor(np.array(E))
6565
rv = self.results()
6666
return pt.wrap_results(rv, E)
6767

68-
#--------------------------------------------------------------------------
68+
# --------------------------------------------------------------------------
6969

7070

7171
def load_lennard_jones_potential(mm):

src/python/structurefinder/pyberny/__init__.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import chemist
16+
import numpy as np
1517
import pluginplay as pp
18+
from berny import Berny, geomlib
1619
from simde import (
1720
EnergyNuclearGradientStdVectorD,
18-
TotalEnergyNuclearOptimization,
1921
MoleculeFromString,
2022
TotalEnergy,
23+
TotalEnergyNuclearOptimization,
2124
)
22-
from berny import Berny, geomlib
23-
import chemist
24-
import numpy as np
2525

2626

2727
class GeomoptViaPyberny(pp.ModuleBase):
28-
2928
def __init__(self):
3029
pp.ModuleBase.__init__(self)
3130
self.satisfies_property_type(TotalEnergyNuclearOptimization())
@@ -43,10 +42,18 @@ def run_(self, inputs, submods):
4342
xyz = ""
4443
xyz += str(molecule.size()) + "\n\n"
4544

46-
#TODO ensure points == molecule.nuclei.charges.point_set
45+
# TODO ensure points == molecule.nuclei.charges.point_set
4746
for i in range(points.size()):
48-
xyz += (molecule.at(i).name + " " + str(points.at(i).x) + " " +
49-
str(points.at(i).y) + " " + str(points.at(i).z) + "\n")
47+
xyz += (
48+
molecule.at(i).name
49+
+ " "
50+
+ str(points.at(i).x)
51+
+ " "
52+
+ str(points.at(i).y)
53+
+ " "
54+
+ str(points.at(i).z)
55+
+ "\n"
56+
)
5057

5158
# Loads the geometry string into the Berny optimizer
5259
# object.
@@ -58,15 +65,17 @@ def run_(self, inputs, submods):
5865
lines = geom2xyz.split("\n")
5966
mol_string = "\n".join(lines[2:])
6067
xyz2chem_mol = submods["StringConv"].run_as(
61-
MoleculeFromString(), mol_string)
68+
MoleculeFromString(), mol_string
69+
)
6270
geom = chemist.ChemicalSystem(xyz2chem_mol)
6371
geom_nuclei = geom.molecule.nuclei.as_nuclei()
6472
geom_points = geom_nuclei.charges.point_set.as_point_set()
6573

6674
# Main optimizer operation
6775
energy = submods["Energy"].run_as(TotalEnergy(), geom)
6876
gradients = submods["Gradient"].run_as(
69-
EnergyNuclearGradientStdVectorD(), geom, geom_points)
77+
EnergyNuclearGradientStdVectorD(), geom, geom_points
78+
)
7079
optimizer.send((np.array(energy).item(), gradients))
7180

7281
opt_geom_nuclei = geom.molecule.nuclei.as_nuclei()

0 commit comments

Comments
 (0)