Skip to content

Commit 4f3d0df

Browse files
authored
Merge pull request #57 from cadenmyers13/pc-blackv2
skpkg: pre-commit auto fixes with line length of 79
2 parents 2202fb8 + 9b9f2a3 commit 4f3d0df

Some content is hidden

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

42 files changed

+392
-147
lines changed

doc/source/examples/distanceprinter.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
#!/usr/bin/env python
22

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

66
from diffpy.srreal.pairquantity import PairQuantity
77
from diffpy.structure import Structure
88

99

1010
class DistancePrinter(PairQuantity):
11-
"""This PairQuantity class simply prints the visited pair distances and the
12-
indices of the contributing atoms."""
11+
"""This PairQuantity class simply prints the visited pair distances
12+
and the indices of the contributing atoms."""
1313

1414
def _resetValue(self):
1515
self.count = 0
1616

1717
def _addPairContribution(self, bnds, sumscale):
1818
self.count += bnds.multiplicity() * sumscale / 2.0
19-
print("%i %g %i %i" % (self.count, bnds.distance(), bnds.site0(), bnds.site1()))
19+
print(
20+
"%i %g %i %i"
21+
% (self.count, bnds.distance(), bnds.site0(), bnds.site1())
22+
)
2023
return
2124

2225

doc/source/examples/lennardjones/ljcalculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

3-
"""Demonstration of using PairQuantity class for calculation of Lennard Jones
4-
potential.
3+
"""Demonstration of using PairQuantity class for calculation of Lennard
4+
Jones potential.
55
66
Vij = 4 * ( rij ** -12 - rij ** -6 )
77
"""

doc/source/examples/parallelPDF.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22

3-
"""Demonstration of parallel PDF calculation using the multiprocessing package.
3+
"""Demonstration of parallel PDF calculation using the multiprocessing
4+
package.
45
56
A PDF of menthol structure is first calculated on a single core and then
67
on all computer CPUs. The script then compares both results and prints
@@ -25,7 +26,11 @@
2526

2627
# configure options parsing
2728
parser = optparse.OptionParser("%prog [options]\n" + __doc__)
28-
parser.add_option("--pyobjcryst", action="store_true", help="Use pyobjcryst to load the CIF file.")
29+
parser.add_option(
30+
"--pyobjcryst",
31+
action="store_true",
32+
help="Use pyobjcryst to load the CIF file.",
33+
)
2934
parser.allow_interspersed_args = True
3035
opts, args = parser.parse_args(sys.argv[1:])
3136

news/pc-blackv2.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* Configure ``black`` to have a linelength requirement of 79 characters.
20+
21+
**Security:**
22+
23+
* <news item>

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ ignore-words = ".codespell/ignore_words.txt"
5757
skip = "*.cif,*.dat"
5858

5959
[tool.black]
60-
line-length = 115
60+
line-length = 79
6161
include = '\.pyi?$'
6262
exclude = '''
6363
/(
@@ -78,3 +78,8 @@ exclude = '''
7878
| tests/data
7979
)/
8080
'''
81+
82+
[tool.docformatter]
83+
recursive = true
84+
wrap-summaries = 72
85+
wrap-descriptions = 72

setup.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def get_boost_config():
3737
conda_prefix = os.environ.get("CONDA_PREFIX")
3838
if not conda_prefix:
3939
raise EnvironmentError(
40-
"Neither BOOST_PATH nor CONDA_PREFIX are set. " "Please install Boost or set BOOST_PATH."
40+
"Neither BOOST_PATH nor CONDA_PREFIX are set. "
41+
"Please install Boost or set BOOST_PATH."
4142
)
4243
if os.name == "nt":
4344
inc = Path(conda_prefix) / "Library" / "include"
@@ -52,7 +53,8 @@ def get_objcryst_libraries():
5253
conda_prefix = os.environ.get("CONDA_PREFIX")
5354
if not conda_prefix:
5455
raise EnvironmentError(
55-
"CONDA_PREFIX is not set. Please install ObjCryst using conda and activate the environment."
56+
"CONDA_PREFIX is not set. "
57+
"Please install ObjCryst using conda and activate the environment."
5658
)
5759
if os.name == "nt":
5860
libdir = Path(conda_prefix) / "Library" / "lib"
@@ -64,7 +66,8 @@ def get_objcryst_libraries():
6466
stem = Path(fn).stem
6567
if "objcryst" not in stem.lower():
6668
continue
67-
# strip a leading "lib" so that setuptools does -lObjCryst, not -llibObjCryst
69+
# strip a leading "lib"
70+
# so that setuptools does -lObjCryst, not -llibObjCryst
6871
if os.name != "nt" and stem.startswith("lib"):
6972
stem = stem[3:]
7073
libs.append(stem)
@@ -99,7 +102,11 @@ def get_objcryst_libraries():
99102

100103
def create_extensions():
101104
"Initialize Extension objects for the setup function."
102-
ext = Extension("diffpy.srreal.srreal_ext", glob.glob("src/extensions/*.cpp"), **ext_kws)
105+
ext = Extension(
106+
"diffpy.srreal.srreal_ext",
107+
glob.glob("src/extensions/*.cpp"),
108+
**ext_kws,
109+
)
103110
return [ext]
104111

105112

src/diffpy/srreal/_docstrings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919

2020
def get_registry_docstrings(cls):
21-
"""Build a dictionary of docstrings per each HasClassRegistry method.
21+
"""Build a dictionary of docstrings per each HasClassRegistry
22+
method.
2223
2324
Parameters
2425
----------

src/diffpy/srreal/_final_imports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525

2626

2727
def import_now():
28-
"""Import all Python modules that tweak extension-defined classes."""
28+
"""Import all Python modules that tweak extension-defined
29+
classes."""
2930
global _import_now_called
3031
if _import_now_called:
3132
return

src/diffpy/srreal/atomradiitable.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def clone(self):
6363
return copy.copy(self)
6464

6565
def type(self):
66-
"""Unique string identifier of the CovalentRadiiTable type. This is
67-
used for class registration and as an argument for the createByType
68-
function.
66+
"""Unique string identifier of the CovalentRadiiTable type. This
67+
is used for class registration and as an argument for the
68+
createByType function.
6969
7070
Return string.
7171
"""

src/diffpy/srreal/attributes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def _getattr(self, name):
3636

3737

3838
def _setattr(self, name, value):
39-
"""Assign to C++ double attribute if Python attribute does not exist."""
39+
"""Assign to C++ double attribute if Python attribute does not
40+
exist."""
4041
try:
4142
object.__getattribute__(self, name)
4243
except AttributeError:

src/diffpy/srreal/bondcalculator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343

4444

4545
def _init_kwargs(self, **kwargs):
46-
"""Create a new instance of BondCalculator. Keyword arguments can be used
47-
to configure calculator properties, for example:
46+
"""Create a new instance of BondCalculator. Keyword arguments can be
47+
used to configure calculator properties, for example:
4848
4949
bdc = BondCalculator(rmin=1.5, rmax=2.5)
5050

src/diffpy/srreal/devutils/tunePeakPrecision.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

3-
"""Tune the peak precision parameter so that PDFCalculator gives equivalent
4-
results to diffpy.pdffit2.
3+
"""Tune the peak precision parameter so that PDFCalculator gives
4+
equivalent results to diffpy.pdffit2.
55
66
Usage: tunePeakPrecision.py [qmax] [peakprecision] [createplot]
77
"""
@@ -108,7 +108,9 @@ def comparePDFCalculators(qmax, peakprecision=None):
108108
rv = {}
109109
rv["qmax"] = qmax
110110
rv["peakprecision"] = (
111-
peakprecision is None and PDFCalculator()._getDoubleAttr("peakprecision") or peakprecision
111+
peakprecision is None
112+
and PDFCalculator()._getDoubleAttr("peakprecision")
113+
or peakprecision
112114
)
113115
ttic = time.clock()
114116
rg0 = Gpdffit2(qmax)
@@ -175,7 +177,10 @@ def main():
175177
processCommandLineArguments()
176178
cmpdata = comparePDFCalculators(qmax, peakprecision)
177179
print(
178-
("qmax = %(qmax)g pkprec = %(peakprecision)g " + "grmsd = %(grmsd)g t0 = %(t0).3f t1 = %(t1).3f")
180+
(
181+
"qmax = %(qmax)g pkprec = %(peakprecision)g "
182+
+ "grmsd = %(grmsd)g t0 = %(t0).3f t1 = %(t1).3f"
183+
)
179184
% cmpdata
180185
)
181186
if createplot:

src/diffpy/srreal/eventticker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See LICENSE.txt for license information.
1313
#
1414
##############################################################################
15-
"""Class EventTicker -- storage of modification times of dependent objects."""
15+
"""Class EventTicker -- storage of modification times of dependent
16+
objects."""
1617

1718

1819
# exported items

src/diffpy/srreal/overlapcalculator.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
"""Class OverlapCalculator -- calculator of atom overlaps in a structure."""
15+
"""Class OverlapCalculator -- calculator of atom overlaps in a
16+
structure."""
1617

1718

1819
# exported items, these also makes them show in pydoc.
@@ -50,8 +51,8 @@
5051

5152

5253
def _init_kwargs(self, **kwargs):
53-
"""Create a new instance of OverlapCalculator. Keyword arguments can be
54-
used to configure calculator properties, for example:
54+
"""Create a new instance of OverlapCalculator. Keyword arguments can
55+
be used to configure calculator properties, for example:
5556
5657
olc = OverlapCalculator(rmax=2.5)
5758

src/diffpy/srreal/pairquantity.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
"""Class PairQuantity -- base class for Python defined calculators."""
15+
"""Class PairQuantity -- base class for Python defined
16+
calculators."""
1617

1718

1819
# exported items

src/diffpy/srreal/parallel.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ def createParallelCalculator(pqobj, ncpu, pmap):
4343
"""
4444

4545
class ParallelPairQuantity(Attributes):
46-
"""Class for running parallel calculations. This is a proxy class to
47-
the wrapper PairQuantity type with the same interface.
46+
"""Class for running parallel calculations. This is a proxy
47+
class to the wrapper PairQuantity type with the same interface.
4848
4949
Instance data:
5050
@@ -70,7 +70,8 @@ def __init__(self, pqobj, ncpu, pmap):
7070
return
7171

7272
def eval(self, stru=None):
73-
"""Perform parallel calculation and return internal value array.
73+
"""Perform parallel calculation and return internal value
74+
array.
7475
7576
stru -- object that can be converted to StructureAdapter,
7677
e.g., example diffpy Structure or pyobjcryst Crystal.
@@ -163,7 +164,9 @@ def proxymethod(self, *args, **kwargs):
163164
return proxymethod
164165

165166
for n, f in inspect.getmembers(pqtype, inspect.isroutine):
166-
ignore = n not in proxy_forced and (n.startswith("_") or hasattr(ParallelPairQuantity, n))
167+
ignore = n not in proxy_forced and (
168+
n.startswith("_") or hasattr(ParallelPairQuantity, n)
169+
)
167170
if ignore:
168171
continue
169172
setattr(ParallelPairQuantity, n, _make_proxymethod(n, f))
@@ -206,7 +209,8 @@ def _fdel(self):
206209

207210

208211
def _parallelData(kwd):
209-
"""Helper for calculating and fetching raw results from a worker node."""
212+
"""Helper for calculating and fetching raw results from a worker
213+
node."""
210214
pqobj = kwd["pqobj"]
211215
pqobj._setupParallelRun(kwd["cpuindex"], kwd["ncpu"])
212216
pqobj.eval()

src/diffpy/srreal/pdfbaseline.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848

4949

5050
def makePDFBaseline(name, fnc, replace=False, **dbattrs):
51-
"""Helper function for registering Python function as a PDFBaseline. This
52-
is required for using Python function as PDFCalculator.baseline.
51+
"""Helper function for registering Python function as a PDFBaseline.
52+
This is required for using Python function as
53+
PDFCalculator.baseline.
5354
5455
name -- unique string name for registering Python function in the
5556
global registry of PDFBaseline types. This will be the
@@ -85,7 +86,9 @@ def fshiftedline(x, aline, bline):
8586
"""
8687
from diffpy.srreal.wraputils import _wrapAsRegisteredUnaryFunction
8788

88-
rv = _wrapAsRegisteredUnaryFunction(PDFBaseline, name, fnc, replace=replace, **dbattrs)
89+
rv = _wrapAsRegisteredUnaryFunction(
90+
PDFBaseline, name, fnc, replace=replace, **dbattrs
91+
)
8992
return rv
9093

9194

src/diffpy/srreal/pdfcalculator.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686

8787

8888
def _defineCommonInterface(cls):
89-
"""This function defines shared properties of PDF calculator classes."""
89+
"""This function defines shared properties of PDF calculator
90+
classes."""
9091

9192
cls.scale = propertyFromExtDoubleAttr(
9293
"scale",
@@ -161,10 +162,10 @@ def _defineCommonInterface(cls):
161162
)
162163

163164
def _call_kwargs(self, structure=None, **kwargs):
164-
"""Calculate PDF for the given structure as an (r, G) tuple. Keyword
165-
arguments can be used to configure calculator attributes, these
166-
override any properties that may be passed from the structure, such as
167-
spdiameter.
165+
"""Calculate PDF for the given structure as an (r, G) tuple.
166+
Keyword arguments can be used to configure calculator
167+
attributes, these override any properties that may be passed
168+
from the structure, such as spdiameter.
168169
169170
structure -- a structure object to be evaluated. Reuse the last
170171
structure when None.

src/diffpy/srreal/pdfenvelope.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@
7777

7878

7979
def makePDFEnvelope(name, fnc, replace=False, **dbattrs):
80-
"""Helper function for registering Python function as a PDFEnvelope. This
81-
is required for using Python function as PDFCalculator envelope.
80+
"""Helper function for registering Python function as a PDFEnvelope.
81+
This is required for using Python function as PDFCalculator
82+
envelope.
8283
8384
name -- unique string name for registering Python function in the
8485
global registry of PDFEnvelope types. This will be the
@@ -115,7 +116,9 @@ def fexpdecay(x, expscale, exptail):
115116
"""
116117
from diffpy.srreal.wraputils import _wrapAsRegisteredUnaryFunction
117118

118-
rv = _wrapAsRegisteredUnaryFunction(PDFEnvelope, name, fnc, replace=replace, **dbattrs)
119+
rv = _wrapAsRegisteredUnaryFunction(
120+
PDFEnvelope, name, fnc, replace=replace, **dbattrs
121+
)
119122
return rv
120123

121124

0 commit comments

Comments
 (0)