Skip to content

Commit b87f9af

Browse files
committed
skpkg: linelength fixes and some copyright updates
1 parent 4197455 commit b87f9af

File tree

7 files changed

+371
-79
lines changed

7 files changed

+371
-79
lines changed

doc/source/conf.py

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
#
4-
# diffpy.pdffit2 documentation build configuration file, created by
4+
# diffpy.pdffit2 documentation build configuration file, created by # noqa: E501
55
# sphinx-quickstart on Thu Jan 30 15:49:41 2014.
66
#
77
# This file is execfile()d with the current directory set to its
@@ -18,6 +18,12 @@
1818
from importlib.metadata import version
1919
from pathlib import Path
2020

21+
# Attempt to import the version dynamically from GitHub tag.
22+
try:
23+
fullversion = version("diffpy.pdffit2")
24+
except Exception:
25+
fullversion = "No version found. The correct version will appear in the released version."
26+
2127
# If extensions (or modules to document with autodoc) are in another directory,
2228
# add these directories to sys.path here. If the directory is relative to the
2329
# documentation root, use Path().resolve() to make it absolute, like shown here.
@@ -26,7 +32,7 @@
2632
sys.path.insert(0, str(Path("../../src").resolve()))
2733

2834
# abbreviations
29-
ab_authors = "Billinge Group members and community contributors"
35+
ab_authors = "Billinge group and community members."
3036

3137
# -- General configuration ------------------------------------------------
3238

@@ -43,6 +49,7 @@
4349
"sphinx.ext.viewcode",
4450
"sphinx.ext.intersphinx",
4551
"sphinx_rtd_theme",
52+
"sphinx_copybutton",
4653
"m2r",
4754
]
4855

@@ -88,6 +95,11 @@
8895
# substitute YEAR in the copyright string
8996
copyright = copyright.replace("%Y", year)
9097

98+
# For sphinx_copybutton extension.
99+
# Do not copy "$" for shell commands in code-blocks.
100+
copybutton_prompt_text = r"^\$ "
101+
copybutton_prompt_is_regexp = True
102+
91103
# List of patterns, relative to source directory, that match files and
92104
# directories to ignore when looking for source files.
93105
exclude_patterns = ["build"]
@@ -123,6 +135,14 @@
123135
#
124136
html_theme = "sphinx_rtd_theme"
125137

138+
html_context = {
139+
"display_github": True,
140+
"github_user": "diffpy",
141+
"github_repo": "diffpy.pdffit2",
142+
"github_version": "main",
143+
"conf_py_path": "/doc/source/",
144+
}
145+
126146
# Theme options are theme-specific and customize the look and feel of a theme
127147
# further. For a list of options available for each theme, see the
128148
# documentation.
@@ -221,7 +241,13 @@
221241
# (source start file, target name, title,
222242
# author, documentclass [howto, manual, or own class]).
223243
latex_documents = [
224-
("index", "diffpy.pdffit2.tex", "diffpy.pdffit2 Documentation", ab_authors, "manual"),
244+
(
245+
"index",
246+
"diffpy.pdffit2.tex",
247+
"diffpy.pdffit2 Documentation",
248+
ab_authors,
249+
"manual",
250+
),
225251
]
226252

227253
# The name of an image file (relative to this directory) to place at the top of
@@ -249,7 +275,15 @@
249275

250276
# One entry per manual page. List of tuples
251277
# (source start file, name, description, authors, manual section).
252-
man_pages = [("index", "diffpy.pdffit2", "diffpy.pdffit2 Documentation", ab_authors, 1)]
278+
man_pages = [
279+
(
280+
"index",
281+
"diffpy.pdffit2",
282+
"diffpy.pdffit2 Documentation",
283+
ab_authors,
284+
1,
285+
)
286+
]
253287

254288
# If true, show URL addresses after external links.
255289
# man_show_urls = False

src/diffpy/pdffit2/pdffit.py

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ def _exportAll(self, namespace):
138138
public = [
139139
a
140140
for a in dir(self)
141-
if "__" not in a and a not in ["_handle", "_exportAll", "selalias", "FCON", "Sctp"]
141+
if "__" not in a
142+
and a not in ["_handle", "_exportAll", "selalias", "FCON", "Sctp"]
142143
]
143144
for funcname in public:
144145
namespace[funcname] = getattr(self, funcname)
@@ -234,12 +235,16 @@ def read_data_string(self, data, stype, qmax, qdamp, name=""):
234235
qdamp -- instrumental Q-resolution factor
235236
name -- tag with which to label data
236237
"""
237-
pdffit2.read_data_string(self._handle, data, stype.encode(), qmax, qdamp, name)
238+
pdffit2.read_data_string(
239+
self._handle, data, stype.encode(), qmax, qdamp, name
240+
)
238241
name = data
239242
self.data_files.append(name)
240243
return
241244

242-
def read_data_lists(self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, name="list"):
245+
def read_data_lists(
246+
self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, name="list"
247+
):
243248
"""read_data_lists(stype, qmax, qdamp, r_data, Gr_data, dGr_data =
244249
None, name = "list") --> Read pdf data into memory from lists.
245250
@@ -255,7 +260,16 @@ def read_data_lists(self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, na
255260
256261
Raises: ValueError when the data lists are of different length
257262
"""
258-
pdffit2.read_data_arrays(self._handle, stype.encode(), qmax, qdamp, r_data, Gr_data, dGr_data, name)
263+
pdffit2.read_data_arrays(
264+
self._handle,
265+
stype.encode(),
266+
qmax,
267+
qdamp,
268+
r_data,
269+
Gr_data,
270+
dGr_data,
271+
name,
272+
)
259273
self.data_files.append(name)
260274
return
261275

@@ -296,7 +310,9 @@ def alloc(self, stype, qmax, qdamp, rmin, rmax, bin):
296310
ValueError for bad input values
297311
pdffit.unassignedError when no structure has been loaded
298312
"""
299-
pdffit2.alloc(self._handle, stype.encode(), qmax, qdamp, rmin, rmax, bin)
313+
pdffit2.alloc(
314+
self._handle, stype.encode(), qmax, qdamp, rmin, rmax, bin
315+
)
300316
return
301317

302318
def calc(self):
@@ -876,8 +892,13 @@ def blen(self, *args):
876892
ij = (args[0], args[1])
877893
# indices were already checked in bond_length_atoms call
878894
assert (0 <= min(ij) - 1) and (max(ij) - 1 < len(atom_symbols))
879-
symij = (atom_symbols[ij[0] - 1].upper(), atom_symbols[ij[1] - 1].upper())
880-
print(_format_bond_length(dij, ddij, ij, symij), file=output.stdout)
895+
symij = (
896+
atom_symbols[ij[0] - 1].upper(),
897+
atom_symbols[ij[1] - 1].upper(),
898+
)
899+
print(
900+
_format_bond_length(dij, ddij, ij, symij), file=output.stdout
901+
)
881902
# second form
882903
elif len(args) == 4:
883904
a1, a2, lb, ub = args
@@ -892,7 +913,12 @@ def blen(self, *args):
892913
return
893914
# arguments are OK here, get bond length dictionary
894915
bld = pdffit2.bond_length_types(self._handle, a1, a2, lb, ub)
895-
s = "(%s,%s) bond lengths in [%gA,%gA] for current phase :" % (a1, a2, lb, ub)
916+
s = "(%s,%s) bond lengths in [%gA,%gA] for current phase :" % (
917+
a1,
918+
a2,
919+
lb,
920+
ub,
921+
)
896922
print(s, file=output.stdout)
897923
atom_symbols = self.get_atoms()
898924
npts = len(bld["dij"])

src/diffpy/pdffit2/version.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22
##############################################################################
33
#
4-
# (c) 2024 The Trustees of Columbia University in the City of New York.
4+
# (c) 2025 The Trustees of Columbia University in the City of New York.
55
# All rights reserved.
66
#
77
# File coded by: Billinge Group members and community contributors.
@@ -38,7 +38,9 @@ def get_pypi_release_date(package_name, timeout=5):
3838
installed_version = version(package_name)
3939
release_data = data["releases"].get(installed_version, [])
4040
if not release_data:
41-
raise ValueError(f"No release data found for version {installed_version}")
41+
raise ValueError(
42+
f"No release data found for version {installed_version}"
43+
)
4244

4345
release_date_str = release_data[-1]["upload_time"]
4446
release_date = datetime.datetime.fromisoformat(release_date_str).date()
@@ -48,7 +50,9 @@ def get_pypi_release_date(package_name, timeout=5):
4850

4951
except (ValueError, OSError) as e:
5052
print(f"Warning: Could not fetch release date from PyPI: {e}")
51-
release_date = datetime.datetime.fromtimestamp(package_file.stat().st_ctime).isoformat()
53+
release_date = datetime.datetime.fromtimestamp(
54+
package_file.stat().st_ctime
55+
).isoformat()
5256

5357
return str(release_date)
5458

0 commit comments

Comments
 (0)