Skip to content

Commit 55349da

Browse files
committed
update doc
1 parent ebc89f7 commit 55349da

File tree

14 files changed

+102
-63
lines changed

14 files changed

+102
-63
lines changed

doc/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ jinja2
33
sphinx
44
numpydoc
55
sphinx_copybutton
6-
sphinx-autodoc-typehints
76
matplotlib
87
sphinx_design
98
nbsphinx

doc/source/conf.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ def _do_not_evaluate(
2020
return _evaluate(self, globalns, *args, **kwargs)
2121
ForwardRef._evaluate = _do_not_evaluate
2222

23+
# Workaround for class attributes
24+
from sphinx.ext.napoleon.docstring import GoogleDocstring
25+
def _parse_attributes_section(self, section):
26+
fields = []
27+
for _name, _type, _desc in self._consume_fields():
28+
if not _type:
29+
_type = self._lookup_annotation(_name)
30+
fields.append((_name, _type, _desc))
31+
return self._format_fields('Attributes', fields)
32+
GoogleDocstring._parse_attributes_section = _parse_attributes_section
33+
34+
2335
project = "pyscfad"
2436
copyright = "2021-2026, Xing Zhang"
2537
author = "Xing Zhang"
@@ -37,13 +49,12 @@ def _do_not_evaluate(
3749
# "IPython.sphinxext.ipython_directive",
3850
# "IPython.sphinxext.ipython_console_highlighting",
3951
"matplotlib.sphinxext.plot_directive",
40-
# "numpydoc",
4152
"sphinx_copybutton",
4253
"sphinx_design",
4354
"sphinx.ext.autodoc",
4455
"sphinx.ext.autosummary",
45-
"sphinx.ext.napoleon", # if using Google/NumPy docstrings
46-
#"sphinx_autodoc_typehints",
56+
# "numpydoc",
57+
"sphinx.ext.napoleon",
4758
"sphinx.ext.coverage",
4859
"sphinx.ext.doctest",
4960
"sphinx.ext.extlinks",
@@ -57,6 +68,13 @@ def _do_not_evaluate(
5768
"myst_nb",
5869
]
5970

71+
intersphinx_mapping = {
72+
'python': ('https://docs.python.org/3/', None),
73+
'numpy': ('https://numpy.org/doc/stable/', None),
74+
'scipy': ('https://scipy.github.io/devdocs/', None),
75+
'pyscf': ('https://pyscf.org/', None),
76+
}
77+
6078
templates_path = ["_templates"]
6179
source_suffix = ['.rst', '.ipynb', '.md']
6280
source_encoding = "utf-8"
@@ -70,8 +88,9 @@ def _do_not_evaluate(
7088
autosummary_generate = True
7189

7290
napolean_use_rtype = False
73-
autodoc_typehints_format = "short"
91+
napoleon_use_ivar = False
7492

93+
autodoc_typehints_format = "short"
7594
autodoc_typehints = "description"
7695
autodoc_typehints_description_target = "all"
7796
autodoc_type_aliases = {

pyscfad/gto/mole_lite.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
1415
"""
15-
Lightweight ``mole`` module.
16+
Lightweight :mod:`~pyscfad.gto.mole` module.
1617
"""
17-
1818
from __future__ import annotations
1919
from collections.abc import Callable
2020
import contextlib
@@ -212,12 +212,12 @@ def intor(
212212
`0` (no symmetry), `1` (hermitian), and `2` (anti-hermitian).
213213
aosym: Permutation symmetry of 2e integrals, can be
214214
`s1`, `s2`, `s4`, and `s8`.
215-
out: Not used.
215+
out: Unused.
216216
shls_slice: Label the start-stop shells for each index in the integral.
217217
For example, the 8-element tuple for the 2e integral
218218
tensor ``(ij|kl) = intor('int2e')`` are specified as
219219
``(i0, i1, j0, j1, k0, k1, l0, l1)``.
220-
grids: Not used.
220+
grids: Unused.
221221
222222
Returns:
223223
Computed integral as an array.
@@ -311,7 +311,7 @@ def from_pyscf(
311311
trace_coords: bool = False,
312312
trace_basis: bool = False,
313313
) -> MoleLite:
314-
"""Initialize from :class:`pyscf.gto.Mole` object.
314+
"""Initialize from the pyscf :class:`~pyscf.gto.mole.Mole` object.
315315
"""
316316
if not mol._built:
317317
raise KeyError(f"{mol} not built")
@@ -348,7 +348,7 @@ def to_pyscf(
348348
output: str | None = None,
349349
max_memory: int | None = None,
350350
) -> MoleBase:
351-
"""Convert to :class:`pyscf.gto.Mole` object.
351+
"""Convert to the pyscf :class:`~pyscf.gto.mole.Mole` object.
352352
"""
353353
coords = ops.to_numpy(self.coords)
354354
atom = [[a, tuple(x.tolist())] for a, x in zip(self.symbols, coords)]
@@ -382,6 +382,7 @@ def gaussian_int(
382382
alpha: ArrayLike,
383383
) -> Array:
384384
r"""Gaussian integral.
385+
385386
Computes :math:`\int_0^\infty x^n exp(-\alpha x^2) dx`.
386387
"""
387388
from pyscfad.scipy.special import gamma
@@ -457,7 +458,7 @@ def make_env(
457458
mol: MoleLite,
458459
) -> tuple[numpy.ndarray, numpy.ndarray, Array]:
459460
"""Make ``_atm``, ``_bas``, and ``_env`` for
460-
interfacing with libcint.
461+
interfacing with ``libcint``.
461462
"""
462463
pre_env = np.zeros(PTR_ENV_START)
463464
_env = [pre_env]

pyscfad/pbc/scf/test/test_hf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,5 +140,5 @@ def hf_energy(cell):
140140
e_tot_ref = mf_ref.kernel()
141141
mf_grad = pyscf_grad.krhf.Gradients(mf_ref)
142142
g0 = mf_grad.kernel()
143-
assert abs(e_tot - e_tot_ref) < 1e-8
144-
assert abs(jac_bwd.coords - g0).max() < 1e-8
143+
assert abs(e_tot - e_tot_ref) < 1e-7
144+
assert abs(jac_bwd.coords - g0).max() < 1e-7

pyscfad/pbc/scf/test/test_khf.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,6 @@ def hf_energy(cell, kpts):
155155
mf_grad = pyscf_grad.krhf.Gradients(mf_ref)
156156
g0 = mf_grad.kernel()
157157

158-
assert abs(e_tot - e_tot_ref) < 1e-8
159-
#assert abs(jac_fwd.coords - g0).max() < 1e-8
160-
assert abs(jac_bwd.coords - g0).max() < 1e-8
158+
assert abs(e_tot - e_tot_ref) < 1e-7
159+
#assert abs(jac_fwd.coords - g0).max() < 1e-7
160+
assert abs(jac_bwd.coords - g0).max() < 1e-7

pyscfad/scf/anderson.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
"""
15+
Anderson mixing
16+
"""
1517
from typing import NamedTuple, Any
1618
import operator
1719
import jax

pyscfad/scf/cphf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
"""
15+
Coupled perturbed Hartree-Fock
16+
"""
1517
from jax.scipy.sparse.linalg import gmres
1618
from pyscfad.lib import logger
1719

pyscfad/scf/diis.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
"""
15+
DIIS
16+
"""
1517
from pyscf.scf import diis as pyscf_cdiis
1618
from pyscfad import numpy as np
1719
from pyscfad import ops

pyscfad/scf/hf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
14+
"""
15+
Restricted Hartree-Fock
16+
"""
1517
from functools import partial
1618
import numpy
1719

pyscfad/scf/hf_lite.py

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

15+
"""
16+
Lightweight :mod:`~pyscfad.scf.hf` module.
17+
"""
1518
from __future__ import annotations
1619
from typing import Any
1720
from functools import partial
@@ -115,9 +118,8 @@ def update_dm(
115118
) -> tuple[float, float, Array, Array, Array, float, Any]:
116119
"""Single SCF step updating the density matrix.
117120
118-
Notes
119-
-----
120-
This function generally has side effects to ``diis``.
121+
Notes:
122+
This function generally has side effects to ``diis``.
121123
"""
122124
log = logger.new_logger(mf)
123125

@@ -291,19 +293,26 @@ def kernel(
291293
return scf_conv, e_tot, mo_energy, mo_coeff, mo_occ
292294

293295
class SCF(SCFBase):
294-
"""Molecular SCF (mean-field) methods.
295-
296-
Parameters
297-
----------
298-
mol
299-
Molecular information.
296+
r"""Molecular SCF (mean-field) methods.
297+
298+
Args:
299+
mol: Molecular information.
300+
301+
Attributes:
302+
diis: SCF solver. Default uses the Anderson mixing.
303+
use_sp2: Whether to use the SP2 density purification solver.
304+
conv_tol_dm: Convergence threshold used for the SP2 solver.
305+
sigma: Smearning temperature :math:`k_B T` in Eh.
306+
smearing_method: Smearning method.
307+
Only Fermi-Dirac (``fermi``) distribution is supported.
308+
veff_with_ecoul: Whether ``get_veff`` returns a :class:`~pyscfad.dft.rks.VXC` object.
300309
"""
301-
diis = None
302-
use_sp2 = False
303-
conv_tol_dm = None
304-
sigma = None
305-
smearing_method = "fermi"
306-
veff_with_ecoul = False
310+
diis: Any | None = None
311+
use_sp2: bool = False
312+
conv_tol_dm: float | None = None
313+
sigma: float | None = None
314+
smearing_method: str = "fermi"
315+
veff_with_ecoul: bool = False
307316

308317
def __init__(
309318
self,
@@ -412,9 +421,8 @@ def mo_mask(
412421
413422
Useful for e.g. padding, where there are fake MOs.
414423
415-
Returns
416-
-------
417-
mask : Mask array where elements with ``True`` values indicate real MOs.
424+
Returns:
425+
mask: Mask array where elements with ``True`` values indicate real MOs.
418426
"""
419427
if mo_energy is None:
420428
mo_energy = self.mo_energy
@@ -442,10 +450,8 @@ def dip_moment(
442450
) -> Array:
443451
"""Molecular dipole moment.
444452
445-
Parameters
446-
----------
447-
charges
448-
Nuclear charges.
453+
Parameters:
454+
charges: Nuclear charges.
449455
"""
450456
if mol is None:
451457
mol = self.mol

0 commit comments

Comments
 (0)