Skip to content

skpkg: pre-commit auto fixes with line length of 79 #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions doc/source/examples/distanceprinter.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
#!/usr/bin/env python

"""Demonstration of using PairQuantity class for a printout of pair distances
in periodic and non-periodic structures."""
"""Demonstration of using PairQuantity class for a printout of pair
distances in periodic and non-periodic structures."""

from diffpy.srreal.pairquantity import PairQuantity
from diffpy.structure import Structure


class DistancePrinter(PairQuantity):
"""This PairQuantity class simply prints the visited pair distances and the
indices of the contributing atoms."""
"""This PairQuantity class simply prints the visited pair distances
and the indices of the contributing atoms."""

def _resetValue(self):
self.count = 0

def _addPairContribution(self, bnds, sumscale):
self.count += bnds.multiplicity() * sumscale / 2.0
print("%i %g %i %i" % (self.count, bnds.distance(), bnds.site0(), bnds.site1()))
print(
"%i %g %i %i"
% (self.count, bnds.distance(), bnds.site0(), bnds.site1())
)
return


Expand Down
4 changes: 2 additions & 2 deletions doc/source/examples/lennardjones/ljcalculator.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

"""Demonstration of using PairQuantity class for calculation of Lennard Jones
potential.
"""Demonstration of using PairQuantity class for calculation of Lennard
Jones potential.

Vij = 4 * ( rij ** -12 - rij ** -6 )
"""
Expand Down
9 changes: 7 additions & 2 deletions doc/source/examples/parallelPDF.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python

"""Demonstration of parallel PDF calculation using the multiprocessing package.
"""Demonstration of parallel PDF calculation using the multiprocessing
package.

A PDF of menthol structure is first calculated on a single core and then
on all computer CPUs. The script then compares both results and prints
Expand All @@ -25,7 +26,11 @@

# configure options parsing
parser = optparse.OptionParser("%prog [options]\n" + __doc__)
parser.add_option("--pyobjcryst", action="store_true", help="Use pyobjcryst to load the CIF file.")
parser.add_option(
"--pyobjcryst",
action="store_true",
help="Use pyobjcryst to load the CIF file.",
)
parser.allow_interspersed_args = True
opts, args = parser.parse_args(sys.argv[1:])

Expand Down
23 changes: 23 additions & 0 deletions news/pc-blackv2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* <news item>

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* Configure ``black`` to have a linelength requirement of 79 characters.

**Security:**

* <news item>
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ ignore-words = ".codespell/ignore_words.txt"
skip = "*.cif,*.dat"

[tool.black]
line-length = 115
line-length = 79
include = '\.pyi?$'
exclude = '''
/(
Expand All @@ -78,3 +78,8 @@ exclude = '''
| tests/data
)/
'''

[tool.docformatter]
recursive = true
wrap-summaries = 72
wrap-descriptions = 72
15 changes: 11 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def get_boost_config():
conda_prefix = os.environ.get("CONDA_PREFIX")
if not conda_prefix:
raise EnvironmentError(
"Neither BOOST_PATH nor CONDA_PREFIX are set. " "Please install Boost or set BOOST_PATH."
"Neither BOOST_PATH nor CONDA_PREFIX are set. "
"Please install Boost or set BOOST_PATH."
)
if os.name == "nt":
inc = Path(conda_prefix) / "Library" / "include"
Expand All @@ -52,7 +53,8 @@ def get_objcryst_libraries():
conda_prefix = os.environ.get("CONDA_PREFIX")
if not conda_prefix:
raise EnvironmentError(
"CONDA_PREFIX is not set. Please install ObjCryst using conda and activate the environment."
"CONDA_PREFIX is not set. "
"Please install ObjCryst using conda and activate the environment."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual line length fix (1 of 2 fixes)

)
if os.name == "nt":
libdir = Path(conda_prefix) / "Library" / "lib"
Expand All @@ -64,7 +66,8 @@ def get_objcryst_libraries():
stem = Path(fn).stem
if "objcryst" not in stem.lower():
continue
# strip a leading "lib" so that setuptools does -lObjCryst, not -llibObjCryst
# strip a leading "lib"
# so that setuptools does -lObjCryst, not -llibObjCryst
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

manual line length fix (2 of 2 fixes)

if os.name != "nt" and stem.startswith("lib"):
stem = stem[3:]
libs.append(stem)
Expand Down Expand Up @@ -99,7 +102,11 @@ def get_objcryst_libraries():

def create_extensions():
"Initialize Extension objects for the setup function."
ext = Extension("diffpy.srreal.srreal_ext", glob.glob("src/extensions/*.cpp"), **ext_kws)
ext = Extension(
"diffpy.srreal.srreal_ext",
glob.glob("src/extensions/*.cpp"),
**ext_kws,
)
return [ext]


Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/srreal/_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@


def get_registry_docstrings(cls):
"""Build a dictionary of docstrings per each HasClassRegistry method.
"""Build a dictionary of docstrings per each HasClassRegistry
method.

Parameters
----------
Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/srreal/_final_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@


def import_now():
"""Import all Python modules that tweak extension-defined classes."""
"""Import all Python modules that tweak extension-defined
classes."""
global _import_now_called
if _import_now_called:
return
Expand Down
6 changes: 3 additions & 3 deletions src/diffpy/srreal/atomradiitable.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ def clone(self):
return copy.copy(self)

def type(self):
"""Unique string identifier of the CovalentRadiiTable type. This is
used for class registration and as an argument for the createByType
function.
"""Unique string identifier of the CovalentRadiiTable type. This
is used for class registration and as an argument for the
createByType function.

Return string.
"""
Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/srreal/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def _getattr(self, name):


def _setattr(self, name, value):
"""Assign to C++ double attribute if Python attribute does not exist."""
"""Assign to C++ double attribute if Python attribute does not
exist."""
try:
object.__getattribute__(self, name)
except AttributeError:
Expand Down
4 changes: 2 additions & 2 deletions src/diffpy/srreal/bondcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@


def _init_kwargs(self, **kwargs):
"""Create a new instance of BondCalculator. Keyword arguments can be used
to configure calculator properties, for example:
"""Create a new instance of BondCalculator. Keyword arguments can be
used to configure calculator properties, for example:

bdc = BondCalculator(rmin=1.5, rmax=2.5)

Expand Down
13 changes: 9 additions & 4 deletions src/diffpy/srreal/devutils/tunePeakPrecision.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python

"""Tune the peak precision parameter so that PDFCalculator gives equivalent
results to diffpy.pdffit2.
"""Tune the peak precision parameter so that PDFCalculator gives
equivalent results to diffpy.pdffit2.

Usage: tunePeakPrecision.py [qmax] [peakprecision] [createplot]
"""
Expand Down Expand Up @@ -108,7 +108,9 @@ def comparePDFCalculators(qmax, peakprecision=None):
rv = {}
rv["qmax"] = qmax
rv["peakprecision"] = (
peakprecision is None and PDFCalculator()._getDoubleAttr("peakprecision") or peakprecision
peakprecision is None
and PDFCalculator()._getDoubleAttr("peakprecision")
or peakprecision
)
ttic = time.clock()
rg0 = Gpdffit2(qmax)
Expand Down Expand Up @@ -175,7 +177,10 @@ def main():
processCommandLineArguments()
cmpdata = comparePDFCalculators(qmax, peakprecision)
print(
("qmax = %(qmax)g pkprec = %(peakprecision)g " + "grmsd = %(grmsd)g t0 = %(t0).3f t1 = %(t1).3f")
(
"qmax = %(qmax)g pkprec = %(peakprecision)g "
+ "grmsd = %(grmsd)g t0 = %(t0).3f t1 = %(t1).3f"
)
% cmpdata
)
if createplot:
Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/srreal/eventticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See LICENSE.txt for license information.
#
##############################################################################
"""Class EventTicker -- storage of modification times of dependent objects."""
"""Class EventTicker -- storage of modification times of dependent
objects."""


# exported items
Expand Down
7 changes: 4 additions & 3 deletions src/diffpy/srreal/overlapcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################
"""Class OverlapCalculator -- calculator of atom overlaps in a structure."""
"""Class OverlapCalculator -- calculator of atom overlaps in a
structure."""


# exported items, these also makes them show in pydoc.
Expand Down Expand Up @@ -50,8 +51,8 @@


def _init_kwargs(self, **kwargs):
"""Create a new instance of OverlapCalculator. Keyword arguments can be
used to configure calculator properties, for example:
"""Create a new instance of OverlapCalculator. Keyword arguments can
be used to configure calculator properties, for example:

olc = OverlapCalculator(rmax=2.5)

Expand Down
3 changes: 2 additions & 1 deletion src/diffpy/srreal/pairquantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# See LICENSE_DANSE.txt for license information.
#
##############################################################################
"""Class PairQuantity -- base class for Python defined calculators."""
"""Class PairQuantity -- base class for Python defined
calculators."""


# exported items
Expand Down
14 changes: 9 additions & 5 deletions src/diffpy/srreal/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ def createParallelCalculator(pqobj, ncpu, pmap):
"""

class ParallelPairQuantity(Attributes):
"""Class for running parallel calculations. This is a proxy class to
the wrapper PairQuantity type with the same interface.
"""Class for running parallel calculations. This is a proxy
class to the wrapper PairQuantity type with the same interface.

Instance data:

Expand All @@ -70,7 +70,8 @@ def __init__(self, pqobj, ncpu, pmap):
return

def eval(self, stru=None):
"""Perform parallel calculation and return internal value array.
"""Perform parallel calculation and return internal value
array.

stru -- object that can be converted to StructureAdapter,
e.g., example diffpy Structure or pyobjcryst Crystal.
Expand Down Expand Up @@ -163,7 +164,9 @@ def proxymethod(self, *args, **kwargs):
return proxymethod

for n, f in inspect.getmembers(pqtype, inspect.isroutine):
ignore = n not in proxy_forced and (n.startswith("_") or hasattr(ParallelPairQuantity, n))
ignore = n not in proxy_forced and (
n.startswith("_") or hasattr(ParallelPairQuantity, n)
)
if ignore:
continue
setattr(ParallelPairQuantity, n, _make_proxymethod(n, f))
Expand Down Expand Up @@ -206,7 +209,8 @@ def _fdel(self):


def _parallelData(kwd):
"""Helper for calculating and fetching raw results from a worker node."""
"""Helper for calculating and fetching raw results from a worker
node."""
pqobj = kwd["pqobj"]
pqobj._setupParallelRun(kwd["cpuindex"], kwd["ncpu"])
pqobj.eval()
Expand Down
9 changes: 6 additions & 3 deletions src/diffpy/srreal/pdfbaseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@


def makePDFBaseline(name, fnc, replace=False, **dbattrs):
"""Helper function for registering Python function as a PDFBaseline. This
is required for using Python function as PDFCalculator.baseline.
"""Helper function for registering Python function as a PDFBaseline.
This is required for using Python function as
PDFCalculator.baseline.

name -- unique string name for registering Python function in the
global registry of PDFBaseline types. This will be the
Expand Down Expand Up @@ -85,7 +86,9 @@ def fshiftedline(x, aline, bline):
"""
from diffpy.srreal.wraputils import _wrapAsRegisteredUnaryFunction

rv = _wrapAsRegisteredUnaryFunction(PDFBaseline, name, fnc, replace=replace, **dbattrs)
rv = _wrapAsRegisteredUnaryFunction(
PDFBaseline, name, fnc, replace=replace, **dbattrs
)
return rv


Expand Down
11 changes: 6 additions & 5 deletions src/diffpy/srreal/pdfcalculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@


def _defineCommonInterface(cls):
"""This function defines shared properties of PDF calculator classes."""
"""This function defines shared properties of PDF calculator
classes."""

cls.scale = propertyFromExtDoubleAttr(
"scale",
Expand Down Expand Up @@ -161,10 +162,10 @@ def _defineCommonInterface(cls):
)

def _call_kwargs(self, structure=None, **kwargs):
"""Calculate PDF for the given structure as an (r, G) tuple. Keyword
arguments can be used to configure calculator attributes, these
override any properties that may be passed from the structure, such as
spdiameter.
"""Calculate PDF for the given structure as an (r, G) tuple.
Keyword arguments can be used to configure calculator
attributes, these override any properties that may be passed
from the structure, such as spdiameter.

structure -- a structure object to be evaluated. Reuse the last
structure when None.
Expand Down
9 changes: 6 additions & 3 deletions src/diffpy/srreal/pdfenvelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@


def makePDFEnvelope(name, fnc, replace=False, **dbattrs):
"""Helper function for registering Python function as a PDFEnvelope. This
is required for using Python function as PDFCalculator envelope.
"""Helper function for registering Python function as a PDFEnvelope.
This is required for using Python function as PDFCalculator
envelope.

name -- unique string name for registering Python function in the
global registry of PDFEnvelope types. This will be the
Expand Down Expand Up @@ -115,7 +116,9 @@ def fexpdecay(x, expscale, exptail):
"""
from diffpy.srreal.wraputils import _wrapAsRegisteredUnaryFunction

rv = _wrapAsRegisteredUnaryFunction(PDFEnvelope, name, fnc, replace=replace, **dbattrs)
rv = _wrapAsRegisteredUnaryFunction(
PDFEnvelope, name, fnc, replace=replace, **dbattrs
)
return rv


Expand Down
Loading
Loading