Skip to content

Commit 78854a4

Browse files
committed
chore: run pre-commit on the repository
1 parent 7963db6 commit 78854a4

6 files changed

Lines changed: 98 additions & 69 deletions

File tree

docs/source/examples/Ni_refinement.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
"""Perform simple refinement of Ni structure to the experimental x-ray PDF.
3+
"""Perform simple refinement of Ni structure to the experimental x-ray
4+
PDF.
45
56
Save fitted curve, refined structure and results summary.
67
"""

src/diffpy/pdffit2/ipy_ext.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-
"""This module defines functions within IPython session to simulate the old
4-
pdffit2 interactive session.
3+
"""This module defines functions within IPython session to simulate the
4+
old pdffit2 interactive session.
55
66
Usage: %load_ext diffpy.pdffit2.ipy_ext
77
"""

src/diffpy/pdffit2/pdffit.py

Lines changed: 70 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ def _format_value_std(value, stdev):
4646

4747

4848
def _format_bond_length(dij, ddij, ij1, symij):
49-
"""Return string with formatted bond length info for a pair of atoms.
49+
"""Return string with formatted bond length info for a pair of
50+
atoms.
5051
5152
dij -- distance between atoms i and j
5253
ddij -- standard deviation of dij. Ignored when small relative to dij.
@@ -123,8 +124,8 @@ class PdfFit(object):
123124
Sctp = {"X": 0, "N": 1}
124125

125126
def _exportAll(self, namespace):
126-
"""_exportAll(self, namespace) --> Export all 'public' class methods
127-
into namespace.
127+
"""_exportAll(self, namespace) --> Export all 'public' class
128+
methods into namespace.
128129
129130
This function allows for a module-level PdfFit object which
130131
doesn't have to be referenced when calling a method. This
@@ -193,8 +194,8 @@ def read_struct(self, struct):
193194
return
194195

195196
def read_struct_string(self, struct, name=""):
196-
"""read_struct_string(struct, name = "") --> Read structure from a
197-
string into memory.
197+
"""read_struct_string(struct, name = "") --> Read structure from
198+
a string into memory.
198199
199200
struct -- string containing the contents of the structure file
200201
name -- tag with which to label structure
@@ -209,8 +210,8 @@ def read_struct_string(self, struct, name=""):
209210
return
210211

211212
def read_data(self, data, stype, qmax, qdamp):
212-
"""read_data(data, stype, qmax, qdamp) --> Read pdf data from file into
213-
memory.
213+
"""read_data(data, stype, qmax, qdamp) --> Read pdf data from
214+
file into memory.
214215
215216
data -- name of file from which to read data
216217
stype -- 'X' (xray) or 'N' (neutron)
@@ -224,8 +225,8 @@ def read_data(self, data, stype, qmax, qdamp):
224225
return
225226

226227
def read_data_string(self, data, stype, qmax, qdamp, name=""):
227-
"""read_data_string(data, stype, qmax, qdamp, name = "") --> Read pdf
228-
data from a string into memory.
228+
"""read_data_string(data, stype, qmax, qdamp, name = "") -->
229+
Read pdf data from a string into memory.
229230
230231
data -- string containing the contents of the data file
231232
stype -- 'X' (xray) or 'N' (neutron)
@@ -243,8 +244,8 @@ def read_data_string(self, data, stype, qmax, qdamp, name=""):
243244
def read_data_lists(
244245
self, stype, qmax, qdamp, r_data, Gr_data, dGr_data=None, name="list"
245246
):
246-
"""read_data_lists(stype, qmax, qdamp, r_data, Gr_data, dGr_data =
247-
None, name = "list") --> Read pdf data into memory from lists.
247+
"""read_data_lists(stype, qmax, qdamp, r_data, Gr_data, dGr_data
248+
= None, name = "list") --> Read pdf data into memory from lists.
248249
249250
All lists must be of the same length.
250251
stype -- 'X' (xray) or 'N' (neutron)
@@ -283,15 +284,16 @@ def pdfrange(self, iset, rmin, rmax):
283284
return
284285

285286
def reset(self):
286-
"""Reset() --> Clear all stored fit, structure, and parameter data."""
287+
"""Reset() --> Clear all stored fit, structure, and parameter
288+
data."""
287289
self.stru_files = []
288290
self.data_files = []
289291
pdffit2.reset(self._handle)
290292
return
291293

292294
def alloc(self, stype, qmax, qdamp, rmin, rmax, bin):
293-
"""Alloc(stype, qmax, qdamp, rmin, rmax, bin) --> Allocate space for a
294-
PDF calculation.
295+
"""Alloc(stype, qmax, qdamp, rmin, rmax, bin) --> Allocate space
296+
for a PDF calculation.
295297
296298
The structure from which to calculate the PDF must first be imported
297299
with the read_struct() or read_struct_string() method.
@@ -328,7 +330,8 @@ def calc(self):
328330
return
329331

330332
def refine(self, toler=0.00000001):
331-
"""Refine(toler = 0.00000001) --> Fit the theory to the imported data.
333+
"""Refine(toler = 0.00000001) --> Fit the theory to the imported
334+
data.
332335
333336
toler -- tolerance of the fit
334337
@@ -347,7 +350,8 @@ def refine(self, toler=0.00000001):
347350
return
348351

349352
def refine_step(self, toler=0.00000001):
350-
"""refine_step(toler = 0.00000001) --> Run a single step of the fit.
353+
"""refine_step(toler = 0.00000001) --> Run a single step of the
354+
fit.
351355
352356
toler -- tolerance of the fit
353357
@@ -364,7 +368,8 @@ def refine_step(self, toler=0.00000001):
364368
return self.finished
365369

366370
def save_pdf(self, iset, fname):
367-
"""save_pdf(iset, fname) --> Save calculated or fitted PDF to file.
371+
"""save_pdf(iset, fname) --> Save calculated or fitted PDF to
372+
file.
368373
369374
iset -- data set to save
370375
@@ -376,7 +381,8 @@ def save_pdf(self, iset, fname):
376381
return
377382

378383
def save_pdf_string(self, iset):
379-
"""save_pdf_string(iset) --> Save calculated or fitted PDF to string.
384+
"""save_pdf_string(iset) --> Save calculated or fitted PDF to
385+
string.
380386
381387
iset -- data set to save
382388
@@ -389,8 +395,8 @@ def save_pdf_string(self, iset):
389395
return pdffilestring
390396

391397
def save_dif(self, iset, fname):
392-
"""save_dif(iset, fname) --> Save data and fitted PDF difference to
393-
file.
398+
"""save_dif(iset, fname) --> Save data and fitted PDF difference
399+
to file.
394400
395401
iset -- data set to save
396402
@@ -402,8 +408,8 @@ def save_dif(self, iset, fname):
402408
return
403409

404410
def save_dif_string(self, iset):
405-
"""save_dif_string(iset) --> Save data and fitted PDF difference to
406-
string.
411+
"""save_dif_string(iset) --> Save data and fitted PDF difference
412+
to string.
407413
408414
iset -- data set to save
409415
@@ -452,8 +458,8 @@ def get_structure(self, ip):
452458
return stru
453459

454460
def save_struct(self, ip, fname):
455-
"""save_struct(ip, fname) --> Save structure resulting from fit to
456-
file.
461+
"""save_struct(ip, fname) --> Save structure resulting from fit
462+
to file.
457463
458464
ip -- phase to save
459465
@@ -465,7 +471,8 @@ def save_struct(self, ip, fname):
465471
return
466472

467473
def save_struct_string(self, ip):
468-
"""save_struct(ip) --> Save structure resulting from fit to string.
474+
"""save_struct(ip) --> Save structure resulting from fit to
475+
string.
469476
470477
ip -- phase to save
471478
@@ -488,7 +495,8 @@ def show_struct(self, ip):
488495
return
489496

490497
def constrain(self, var, par, fcon=None):
491-
"""Constrain(var, par[, fcon]) --> Constrain a variable to a parameter.
498+
"""Constrain(var, par[, fcon]) --> Constrain a variable to a
499+
parameter.
492500
493501
A variable can be constrained to a number or equation string.
494502
@@ -648,7 +656,8 @@ def getpdf_diff(self):
648656
return Gdiff
649657

650658
def get_atoms(self, ip=None):
651-
"""get_atoms() --> Get element symbols of all atoms in the structure.
659+
"""get_atoms() --> Get element symbols of all atoms in the
660+
structure.
652661
653662
ip -- index of phase to get the elements from (starting from 1)
654663
when ip is not given, use current phase
@@ -754,7 +763,8 @@ def psel(self, ip):
754763
return
755764

756765
def pdesel(self, ip):
757-
"""Pdesel(ip) --> Exclude phase ip from calculation of total PDF.
766+
"""Pdesel(ip) --> Exclude phase ip from calculation of total
767+
PDF.
758768
759769
pdesel('ALL') excludes all phases from PDF calculation.
760770
@@ -851,9 +861,9 @@ def bang(self, i, j, k):
851861
return
852862

853863
def bond_angle(self, i, j, k):
854-
"""bond_angle(i, j, k) --> bond angle defined by atoms i, j, k. Angle
855-
is calculated using the shortest ji and jk lengths with respect to
856-
periodic boundary conditions.
864+
"""bond_angle(i, j, k) --> bond angle defined by atoms i, j, k.
865+
Angle is calculated using the shortest ji and jk lengths with
866+
respect to periodic boundary conditions.
857867
858868
i, j, k -- atom indices starting at 1
859869
@@ -942,8 +952,9 @@ def blen(self, *args):
942952
return
943953

944954
def bond_length_atoms(self, i, j):
945-
"""bond_length_atoms(i, j) --> shortest distance between atoms i, j.
946-
Periodic boundary conditions are applied to find the shortest bond.
955+
"""bond_length_atoms(i, j) --> shortest distance between atoms
956+
i, j. Periodic boundary conditions are applied to find the
957+
shortest bond.
947958
948959
i -- index of the first atom starting at 1
949960
j -- index of the second atom starting at 1
@@ -957,7 +968,8 @@ def bond_length_atoms(self, i, j):
957968
return rv
958969

959970
def bond_length_types(self, a1, a2, lb, ub):
960-
"""bond_length_types(a1, a2, lb, ub) --> get all a1-a2 distances.
971+
"""bond_length_types(a1, a2, lb, ub) --> get all a1-a2
972+
distances.
961973
962974
a1 -- symbol of the first element in pair or "ALL"
963975
a2 -- symbol of the second element in pair or "ALL"
@@ -978,8 +990,8 @@ def bond_length_types(self, a1, a2, lb, ub):
978990
return rv
979991

980992
def show_scat(self, stype):
981-
"""show_scat(stype) --> Print scattering length for all atoms in the
982-
current phase.
993+
"""show_scat(stype) --> Print scattering length for all atoms in
994+
the current phase.
983995
984996
stype -- 'X' (xray) or 'N' (neutron).
985997
@@ -989,8 +1001,8 @@ def show_scat(self, stype):
9891001
return
9901002

9911003
def get_scat_string(self, stype):
992-
"""get_scat_string(stype) --> Get string with scattering factors of all
993-
atoms in the current phase.
1004+
"""get_scat_string(stype) --> Get string with scattering factors
1005+
of all atoms in the current phase.
9941006
9951007
stype -- 'X' (xray) or 'N' (neutron).
9961008
@@ -1002,10 +1014,10 @@ def get_scat_string(self, stype):
10021014
return pdffit2.get_scat_string(self._handle, stype.encode())
10031015

10041016
def get_scat(self, stype, element):
1005-
"""get_scat(stype, element) --> Get active scattering factor for given
1006-
element. If scattering factor has been changed using set_scat the
1007-
result may depend on the active phase. When no phase has been loaded,
1008-
return the standard value.
1017+
"""get_scat(stype, element) --> Get active scattering factor for
1018+
given element. If scattering factor has been changed using
1019+
set_scat the result may depend on the active phase. When no
1020+
phase has been loaded, return the standard value.
10091021
10101022
stype -- 'X' (xray) or 'N' (neutron).
10111023
element -- case-insensitive element symbol such as "Na" or "CL"
@@ -1019,9 +1031,10 @@ def get_scat(self, stype, element):
10191031
return rv
10201032

10211033
def set_scat(self, stype, element, value):
1022-
"""set_scat(stype, element, value) --> Set custom scattering factor for
1023-
given element. The new scattering factor applies only for the current
1024-
phase, in other phases it keeps its default value.
1034+
"""set_scat(stype, element, value) --> Set custom scattering
1035+
factor for given element. The new scattering factor applies
1036+
only for the current phase, in other phases it keeps its default
1037+
value.
10251038
10261039
stype -- 'X' (xray) or 'N' (neutron).
10271040
element -- case-insensitive element symbol such as "Na" or "CL"
@@ -1039,9 +1052,9 @@ def set_scat(self, stype, element, value):
10391052
return
10401053

10411054
def reset_scat(self, element):
1042-
"""reset_scat(stype, element) --> Reset scattering factors for given
1043-
element to their standard values. The reset_scat applies only for the
1044-
current phase.
1055+
"""reset_scat(stype, element) --> Reset scattering factors for
1056+
given element to their standard values. The reset_scat applies
1057+
only for the current phase.
10451058
10461059
element -- case-insensitive element symbol such as "Na" or "CL"
10471060
Raises:
@@ -1069,7 +1082,8 @@ def num_phases(self):
10691082
return n
10701083

10711084
def num_datasets(self):
1072-
"""num_datasets() --> Number of datasets loaded in PdfFit instance.
1085+
"""num_datasets() --> Number of datasets loaded in PdfFit
1086+
instance.
10731087
10741088
Use setdata to bring a specific dataset in focus.
10751089
@@ -1079,9 +1093,9 @@ def num_datasets(self):
10791093
return n
10801094

10811095
def phase_fractions(self):
1082-
"""phase_fractions() --> relative phase fractions for current dataset.
1083-
Convert phase scale factors to relative phase fractions given the
1084-
scattering type of current dataset.
1096+
"""phase_fractions() --> relative phase fractions for current
1097+
dataset. Convert phase scale factors to relative phase fractions
1098+
given the scattering type of current dataset.
10851099
10861100
Return a dictionary of phase fractions with following keys:
10871101
@@ -1254,7 +1268,8 @@ def qbroad():
12541268
qbroad = staticmethod(qbroad)
12551269

12561270
def spdiameter():
1257-
"""Spdiameter() --> Get reference to spdiameter (phase property).
1271+
"""Spdiameter() --> Get reference to spdiameter (phase
1272+
property).
12581273
12591274
Diameter value for the spherical particle PDF correction.
12601275
Spherical envelope is not applied when spdiameter equals 0.
@@ -1307,7 +1322,8 @@ def __init__(self, create_intro=True):
13071322
return
13081323

13091324
def __getRef(self, var_string):
1310-
"""Return the actual reference to the variable in the var_string.
1325+
"""Return the actual reference to the variable in the
1326+
var_string.
13111327
13121328
This function must be called before trying to actually reference an
13131329
internal variable. See the constrain method for an example.

0 commit comments

Comments
 (0)