diff --git a/doc/source/manual_resources/tui_mno_bond_lengths.py b/doc/source/manual_resources/tui_mno_bond_lengths.py index febd0b51..a1d1f679 100755 --- a/doc/source/manual_resources/tui_mno_bond_lengths.py +++ b/doc/source/manual_resources/tui_mno_bond_lengths.py @@ -1,6 +1,7 @@ #!/usr/bin/env python -"""Extract the shortest Mn-O bond lengths from all fits in PDFgui project. +"""Extract the shortest Mn-O bond lengths from all fits in PDFgui +project. This script loops through all refined phases in PDFgui project and calculates their shortest Mn-O bond lengths using diffpy.pdffit2 diff --git a/pyproject.toml b/pyproject.toml index f46d1752..cd6baea4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,3 +81,7 @@ exclude = ''' | tests/data )/ ''' +[tool.docformatter] +recursive = true +wrap-summaries = 72 +wrap-descriptions = 72 diff --git a/src/diffpy/pdfgui/applications/pdfgui.py b/src/diffpy/pdfgui/applications/pdfgui.py index 99b5e734..cb6166a2 100755 --- a/src/diffpy/pdfgui/applications/pdfgui.py +++ b/src/diffpy/pdfgui/applications/pdfgui.py @@ -54,9 +54,9 @@ def version(): def processArguments(argv1): - """Process command line arguments and store results in pdfguiglobals. This - method updates cmdopts, cmdargs and dbopts attributes in the pdfguiglobals - module. + """Process command line arguments and store results in + pdfguiglobals. This method updates cmdopts, cmdargs and dbopts + attributes in the pdfguiglobals module. argv1 -- list of command line arguments excluding the executable diff --git a/src/diffpy/pdfgui/control/calculation.py b/src/diffpy/pdfgui/control/calculation.py index 28be348e..c8e86a44 100644 --- a/src/diffpy/pdfgui/control/calculation.py +++ b/src/diffpy/pdfgui/control/calculation.py @@ -12,7 +12,8 @@ # See LICENSE.txt for license information. # ############################################################################## -"""Class Calculation for performing PDF simulation from model structure.""" +"""Class Calculation for performing PDF simulation from model +structure.""" import copy import math @@ -76,8 +77,8 @@ def _getStrId(self): return "c_" + self.name def setRGrid(self, rmin=None, rstep=None, rmax=None): - """Change specified r-grid parameters (rmin, rstep, rmax). Adjust rmax - for integer number of steps. + """Change specified r-grid parameters (rmin, rstep, rmax). + Adjust rmax for integer number of steps. rmin -- new low rcalc boundary rstep -- new r-grid step diff --git a/src/diffpy/pdfgui/control/constraint.py b/src/diffpy/pdfgui/control/constraint.py index 2dd2ce12..54a5daa4 100644 --- a/src/diffpy/pdfgui/control/constraint.py +++ b/src/diffpy/pdfgui/control/constraint.py @@ -12,8 +12,8 @@ # See LICENSE.txt for license information. # ############################################################################## -"""Class Constraint for storage of a single constraint equation constraints -will be stored in { variable : constraint } dictionary.""" +"""Class Constraint for storage of a single constraint equation +constraints will be stored in { variable : constraint } dictionary.""" import math import re @@ -67,8 +67,8 @@ def evalFormula(self, parvalues): return result def lambdaFormula(self): - """Build lambda function from constraint formula. Lambda function - expects dictionary argument. + """Build lambda function from constraint formula. Lambda + function expects dictionary argument. returns lambda function """ diff --git a/src/diffpy/pdfgui/control/controlerrors.py b/src/diffpy/pdfgui/control/controlerrors.py index 84e2ba4c..b7fd47d3 100644 --- a/src/diffpy/pdfgui/control/controlerrors.py +++ b/src/diffpy/pdfgui/control/controlerrors.py @@ -42,7 +42,8 @@ class ControlFileError(ControlError): class ControlKeyError(ControlError): - """PDFGuiControl exception class -- requested object can't be found.""" + """PDFGuiControl exception class -- requested object can't be + found.""" pass @@ -66,7 +67,8 @@ class ControlStatusError(ControlError): class ControlRuntimeError(ControlError): - """PDFGuiControl exception class -- various irrecoverable runtime error.""" + """PDFGuiControl exception class -- various irrecoverable runtime + error.""" pass @@ -85,8 +87,8 @@ class ControlSyntaxError(ControlError): class TempControlSelectError(ControlError): - """Temporary define this error to identify the select-control error in - python3.""" + """Temporary define this error to identify the select-control error + in python3.""" pass diff --git a/src/diffpy/pdfgui/control/fitdataset.py b/src/diffpy/pdfgui/control/fitdataset.py index 11c490d7..a9147658 100644 --- a/src/diffpy/pdfgui/control/fitdataset.py +++ b/src/diffpy/pdfgui/control/fitdataset.py @@ -26,8 +26,8 @@ class FitDataSet(PDFDataSet): - """FitDataSet stores experimental and calculated PDF data and related - fitting parameters. Inherited from PDFDataSet. + """FitDataSet stores experimental and calculated PDF data and + related fitting parameters. Inherited from PDFDataSet. Data members (in addition to those in PDFDataSet): @@ -204,8 +204,8 @@ def read(self, filename): return self.readObs(filename) def _updateRcalcRange(self): - """Helper method for updating fitrmin, fitrmax and fitrstep just after - reading observed values. + """Helper method for updating fitrmin, fitrmax and fitrstep just + after reading observed values. No return value. """ @@ -243,7 +243,8 @@ def readObsStr(self, datastring): return self def write(self, filename): - """Same as writeCalc(). Use writeObs() to save experimental PDF data. + """Same as writeCalc(). Use writeObs() to save experimental PDF + data. filename -- name of file to write to @@ -266,7 +267,8 @@ def writeCalc(self, filename): return def writeStr(self): - """Same as writeCalcStr. Use writeObsStr() for experimental PDF. + """Same as writeCalcStr. Use writeObsStr() for experimental + PDF. Return data string. """ @@ -377,9 +379,9 @@ def writeResampledObsStr(self): return s def findParameters(self): - """Obtain dictionary of parameters used by self.constraints. The keys - of returned dictionary are integer parameter indices, and their values - Parameter instances, with guessed initial values. + """Obtain dictionary of parameters used by self.constraints. The + keys of returned dictionary are integer parameter indices, and + their values Parameter instances, with guessed initial values. returns dictionary of indices and Parameter instances """ @@ -527,9 +529,9 @@ def save(self, z, subpath): # interface for data sampling def getFitSamplingType(self): - """Description of r-sampling used in the fit. This method compares - self.fitrstep with r-sampling in the observed data and with Nyquist r - step. + """Description of r-sampling used in the fit. This method + compares self.fitrstep with r-sampling in the observed data and + with Nyquist r step. Return a string, possible values are "data", "Nyquist" or "custom". @@ -568,7 +570,8 @@ def setFitSamplingType(self, tp, value=None): return def getObsSampling(self): - """Return the average r-step used in robs or zero when not defined.""" + """Return the average r-step used in robs or zero when not + defined.""" n = len(self.robs) if n > 1: rv = (self.robs[-1] - self.robs[0]) / (n - 1.0) @@ -577,7 +580,8 @@ def getObsSampling(self): return rv def getNyquistSampling(self): - """Return r-step corresponding to Nyquist sampling at the qmax value. + """Return r-step corresponding to Nyquist sampling at the qmax + value. When qmax is zero, return r-step in the observed data. """ @@ -590,9 +594,9 @@ def getNyquistSampling(self): # Property Attributes def _updateRcalcSampling(self): - """Helper method for resampling rcalc and interpolating related data. - This method interpolates Gcalc, dGcalc, Gtrunc, dGtrunc, crw to new r - grid. + """Helper method for resampling rcalc and interpolating related + data. This method interpolates Gcalc, dGcalc, Gtrunc, dGtrunc, + crw to new r grid. No return value. """ @@ -815,8 +819,8 @@ def _linear_interpolation(x0, y0, x1, youtleft, youtright): def grid_interpolation(x0, y0, x1, left=None, right=None, tp=None): - """Interpolate values from one grid onto another using either linear or - Whittaker–Shannon interpolation. + """Interpolate values from one grid onto another using either linear + or Whittaker–Shannon interpolation. Parameters ---------- diff --git a/src/diffpy/pdfgui/control/fitstructure.py b/src/diffpy/pdfgui/control/fitstructure.py index e31372cc..d4141c56 100644 --- a/src/diffpy/pdfgui/control/fitstructure.py +++ b/src/diffpy/pdfgui/control/fitstructure.py @@ -78,8 +78,8 @@ def __init__(self, name, *args, **kwargs): return def _update_custom_spacegroup(self, parser): - """Helper method for read() and readStr(), which takes care of setting - custom_spacegroup after successful reading. + """Helper method for read() and readStr(), which takes care of + setting custom_spacegroup after successful reading. parser -- instance of StructureParser used in reading. @@ -99,9 +99,9 @@ def _update_custom_spacegroup(self, parser): return def read(self, filename, format="auto"): - """Load structure from a file, raise ControlFileError for invalid or - unknown structure format. Overloads PDFStructure.read() to handle - custom_spacegroup attribute. + """Load structure from a file, raise ControlFileError for + invalid or unknown structure format. Overloads + PDFStructure.read() to handle custom_spacegroup attribute. filename -- file to be loaded format -- structure format such as 'pdffit', 'pdb', 'xyz'. When @@ -119,7 +119,8 @@ def read(self, filename, format="auto"): return p def readStr(self, s, format="auto"): - """Same as PDFStructure.readStr, but handle the custom_spacegroup data. + """Same as PDFStructure.readStr, but handle the + custom_spacegroup data. Return instance of StructureParser used to load the data. See Structure.readStr() for more info. @@ -169,9 +170,9 @@ def obtainRefined(self, server, iphase): return def findParameters(self): - """Obtain dictionary of parameters used by self.constraints. The keys - of returned dictionary are integer parameter indices, and the values - are Parameter instances, with guessed initial values. + """Obtain dictionary of parameters used by self.constraints. The + keys of returned dictionary are integer parameter indices, and + the values are Parameter instances, with guessed initial values. returns dictionary of indices and Parameter instances """ @@ -244,9 +245,9 @@ def _popAtomConstraints(self): return rv def _restoreAtomConstraints(self, acd): - """Restore self.constraints from atom constraints dictionary. This is - useful for getting correct atom indices into refvar strings. See also - _popAtomConstraints() + """Restore self.constraints from atom constraints dictionary. + This is useful for getting correct atom indices into refvar + strings. See also _popAtomConstraints() acd -- dictionary obtained from _popAtomConstraints() """ @@ -262,7 +263,8 @@ def _restoreAtomConstraints(self, acd): return def insertAtoms(self, index, atomlist): - """Insert list of atoms before index and adjust self.constraints. + """Insert list of atoms before index and adjust + self.constraints. index -- position in the initial structure, atoms are appended when larger than len(self.initial). @@ -295,8 +297,8 @@ def expandSuperCell(self, mno): """Perform supercell expansion for this structure and adjust constraints for positions and lattice parameters. New lattice parameters are multiplied and fractional coordinates divided by - corresponding multiplier. New atoms are grouped with their source in - the original cell. + corresponding multiplier. New atoms are grouped with their + source in the original cell. mno -- tuple or list of three positive integer cell multipliers along the a, b, c axis @@ -369,8 +371,8 @@ def isSpaceGroupPossible(self, spacegroup): return isSpaceGroupLatPar(spacegroup, *self.initial.lattice.abcABG()) def getSpaceGroupList(self): - """Return a list of SpaceGroup instances sorted by International Tables - number. + """Return a list of SpaceGroup instances sorted by International + Tables number. When custom_spacegroup is defined, the list starts with custom_spacegroup. @@ -394,8 +396,9 @@ def getSpaceGroupList(self): return sglist def getSpaceGroup(self, sgname): - """Find space group in getSpaceGroupList() by short_name or number. - sgname can be non-standard in case of CIF file defined space group. + """Find space group in getSpaceGroupList() by short_name or + number. sgname can be non-standard in case of CIF file defined + space group. Return instance of SpaceGroup. Raise ValueError if sgname cannot be found or when it is not present in getSpaceGroupList(). @@ -414,11 +417,11 @@ def getSpaceGroup(self, sgname): return sgfound def expandAsymmetricUnit(self, spacegroup, indices, sgoffset=[0, 0, 0]): - """Perform symmetry expansion for atoms at given indices. Temperature - factors may be corrected to reflect the symmetry. All constraints for - expanded atoms are erased with the exception of the occupancy("occ". - Constraints of unaffected atoms are adjusted for new positions - self.initial. + """Perform symmetry expansion for atoms at given indices. + Temperature factors may be corrected to reflect the symmetry. + All constraints for expanded atoms are erased with the exception + of the occupancy("occ". Constraints of unaffected atoms are + adjusted for new positions self.initial. spacegroup -- instance of SpaceGroup from diffpy.structure indices -- list of integer indices of atoms to be expanded @@ -462,10 +465,11 @@ def expandAsymmetricUnit(self, spacegroup, indices, sgoffset=[0, 0, 0]): return def applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag, sgoffset=[0, 0, 0]): - """Generate symmetry constraints for positions and thermal factors. - Both positions and thermal factors may get corrected to reflect space - group symmetry. Old positional and thermal constraints get erased. New - parameter indices start at fist decade after the last used parameter. + """Generate symmetry constraints for positions and thermal + factors. Both positions and thermal factors may get corrected to + reflect space group symmetry. Old positional and thermal + constraints get erased. New parameter indices start at fist + decade after the last used parameter. spacegroup -- instance of SpaceGroup from diffpy.structure indices -- list of integer indices of atoms to be expanded @@ -539,9 +543,9 @@ def applySymmetryConstraints(self, spacegroup, indices, posflag, Uijflag, sgoffs return def setSelectedPairs(self, s): - """Set the value of selected_pairs to s, raise ControlValueError when s - has invalid syntax. The selected_pairs is a comma separated list of - words formatted as. + """Set the value of selected_pairs to s, raise ControlValueError + when s has invalid syntax. The selected_pairs is a comma + separated list of words formatted as. [!]{element|indexOrRange|all}-[!]{element|indexOrRange|all} @@ -570,9 +574,10 @@ def getSelectedPairs(self): return self.selected_pairs def getPairSelectionFlags(self, s=None): - """Translate string s to a list of allowed values for first and second - pair index. Raise ControlValueError for invalid syntax of s. See - setSelectedPairs() docstring for a definition of pair selection syntax. + """Translate string s to a list of allowed values for first and + second pair index. Raise ControlValueError for invalid syntax + of s. See setSelectedPairs() docstring for a definition of pair + selection syntax. s -- string describing selected pairs (default: self.selected_pairs) @@ -628,7 +633,8 @@ def applyPairSelection(self, server, phaseidx): return def getSelectedIndices(self, s): - """Indices of the atoms that match the specified selection string. + """Indices of the atoms that match the specified selection + string. s -- selection string consisting of one or more atom selection words formatted as [!]{element|indexOrRange|all} @@ -655,7 +661,8 @@ def getSelectedIndices(self, s): _rxatomselection = None def _parseAtomSelectionString(self, s): - """Process string that describes a set of atoms in the structure. + """Process string that describes a set of atoms in the + structure. s -- selection string formatted as [!]{element|indexOrRange|all} "!" negates the selection, indexOrRange can be 1, 1:4, @@ -847,11 +854,11 @@ def getData(self, name, step=-1): def _makeParNames(sympars, parzeroindex): - """Return a tuple of (symbols, parvalues), where symbols is a list of - unique PDFFit parameter strings in "@%i" format and parvalues is a - dictionary of parameter indices and their values. The symbols have indices - 10n + (1, 2, 3) when referring to x, y, z, or 10n + (4, 5, 6, 7, 8, 9) when - referring to Uij. + """Return a tuple of (symbols, parvalues), where symbols is a list + of unique PDFFit parameter strings in "@%i" format and parvalues is + a dictionary of parameter indices and their values. The symbols have + indices 10n + (1, 2, 3) when referring to x, y, z, or 10n + (4, 5, + 6, 7, 8, 9) when referring to Uij. sympars -- pospars or Upars attribute of a SymmetryConstraints object Must be a sequence of symbols and values. diff --git a/src/diffpy/pdfgui/control/fitting.py b/src/diffpy/pdfgui/control/fitting.py index c33a6b8b..d6b7dc6a 100644 --- a/src/diffpy/pdfgui/control/fitting.py +++ b/src/diffpy/pdfgui/control/fitting.py @@ -27,7 +27,8 @@ def getEngineExceptions(): - """Return a tuple of possible exceptions from diffpy.pdffit2.pdffit2.""" + """Return a tuple of possible exceptions from + diffpy.pdffit2.pdffit2.""" from diffpy.pdffit2.pdffit2 import ( calculationError, constraintError, @@ -278,7 +279,8 @@ def updateParameters(self): return self.parameters def applyParameters(self): - """Evaluate all constrained variables using current parameters.""" + """Evaluate all constrained variables using current + parameters.""" for struc in self.strucs: struc.applyParameters(self.parameters) for dataset in self.datasets: @@ -446,9 +448,9 @@ def _configureBondCalculation(self, struc): return def outputBondAngle(self, struc, i, j, k): - """Output bond angle defined by atoms i, j, k. The angle is calculated - using the shortest lengths ji and jk with respect to periodic boundary - conditions. + """Output bond angle defined by atoms i, j, k. The angle is + calculated using the shortest lengths ji and jk with respect to + periodic boundary conditions. struc -- instance of PDFStructure i, j, k -- atom indices starting at 1 @@ -586,8 +588,8 @@ def close(self, force=False): self.thread.join() def buildNameDict(self): - """Build up a data name dictionary, which will map data name to a - unique index. + """Build up a data name dictionary, which will map data name to + a unique index. The private dataNameDict has such structure: { 'd_data1':{'Gobs':12, 'Gcalc':11, ....}, @@ -636,8 +638,8 @@ def buildNameDict(self): self.dataNameDict = dataNameDict def appendStep(self, source): - """After a refinement step is done, append all data from self to the - historical storage, i.e., self.snapshots. + """After a refinement step is done, append all data from self to + the historical storage, i.e., self.snapshots. source -- where to get the fitted data, in deed it's a PdfFit2 instance """ diff --git a/src/diffpy/pdfgui/control/organizer.py b/src/diffpy/pdfgui/control/organizer.py index cb0787b4..adadf6cd 100644 --- a/src/diffpy/pdfgui/control/organizer.py +++ b/src/diffpy/pdfgui/control/organizer.py @@ -30,8 +30,8 @@ def spd_constrained(ds): class Organizer(PDFComponent): - """Base class for Fitting. It holds separate lists of datasets, strucs and - calculations. + """Base class for Fitting. It holds separate lists of datasets, + strucs and calculations. datasets: dataset list strucs: structure list @@ -240,7 +240,8 @@ def organization(self): return org def __forward_spdiameter(self): - """Copy spdiameter value loaded from fit or calculation to phase. + """Copy spdiameter value loaded from fit or calculation to + phase. This method takes care of loading old PDFgui projects where spdiameter belonged to FitDataSet or Calculation classes. It diff --git a/src/diffpy/pdfgui/control/parameter.py b/src/diffpy/pdfgui/control/parameter.py index a4410ee4..b366c856 100644 --- a/src/diffpy/pdfgui/control/parameter.py +++ b/src/diffpy/pdfgui/control/parameter.py @@ -25,8 +25,9 @@ class Parameter: """Parameter is class for value and properties of refined parameter. - Because the initial value of Parameter may come from another Fitting, it is - accessed by setInitial(), initialStr() and initialValue() methods. + Because the initial value of Parameter may come from another + Fitting, it is accessed by setInitial(), initialStr() and + initialValue() methods. Data members: idx -- integer identifier of this parameter in PdfFit @@ -58,7 +59,8 @@ def __init__(self, idx, initial=0.0): return def setInitial(self, initial): - """Set initial value to float or refined value from another Fitting. + """Set initial value to float or refined value from another + Fitting. initial -- initial value, it can be something convertible to float, Fitting reference or string in "=fitname" or @@ -150,9 +152,10 @@ def __getLinkedValue(self): return value def __findLinkedFitting(self): - """Private search for linked Fitting by name and by representation. - Should be called only when initial value is linked to another Fitting. - Updates self.__initial and self.__fitrepr. + """Private search for linked Fitting by name and by + representation. Should be called only when initial value is + linked to another Fitting. Updates self.__initial and + self.__fitrepr. returns reference to Fitting when found or None """ diff --git a/src/diffpy/pdfgui/control/pdfdataset.py b/src/diffpy/pdfgui/control/pdfdataset.py index 1027e067..34b6efba 100644 --- a/src/diffpy/pdfgui/control/pdfdataset.py +++ b/src/diffpy/pdfgui/control/pdfdataset.py @@ -116,8 +116,8 @@ def setvar(self, var, value): return def getvar(self, var): - """Obtain value corresponding to PdfFit dataset variable. Used by - findParameters(). + """Obtain value corresponding to PdfFit dataset variable. Used + by findParameters(). var -- string representation of dataset PdfFit variable. Possible values: qdamp, qbroad, dscale diff --git a/src/diffpy/pdfgui/control/pdfguicontrol.py b/src/diffpy/pdfgui/control/pdfguicontrol.py index d1eb4d6b..695a15ac 100644 --- a/src/diffpy/pdfgui/control/pdfguicontrol.py +++ b/src/diffpy/pdfgui/control/pdfguicontrol.py @@ -34,8 +34,8 @@ class PDFGuiControl: - """PDFGuiControl holds all the data GUI needs to access or change It has a - container of Calculation and Fitting instances. + """PDFGuiControl holds all the data GUI needs to access or change It + has a container of Calculation and Fitting instances. Each Calculation and Fitting has a unique name. """ @@ -274,7 +274,8 @@ def __findOwner(self, ID): raise ControlTypeError("Object %s doesn't exit in the list" % ID.name) def rename(self, ID, new_name): - """Rename Fitting, Calculation, Dataset or Structure identified by ID. + """Rename Fitting, Calculation, Dataset or Structure identified + by ID. ID: reference to the object to be renamed new_name: new name to be given to the object @@ -283,7 +284,8 @@ def rename(self, ID, new_name): container.rename(ID, new_name) def remove(self, ID): - """Remove Fitting, Calculation, Dataset or Structure identified by ID. + """Remove Fitting, Calculation, Dataset or Structure identified + by ID. ID: reference to the object to be removed return: removed object @@ -311,8 +313,8 @@ def copy(self, src): return newObject def paste(self, dup, target=None, new_name=None, position=None): - """Paste copied object to target under new_name, the default new_name - will be name of src. + """Paste copied object to target under new_name, the default + new_name will be name of src. dup -- reference to the copied object target -- target object where the copy should be inserted @@ -532,7 +534,8 @@ def getEngineOutput(self): def pdfguicontrol(*args, **kwargs): - """This function will return the single instance of class PDFGuiControl.""" + """This function will return the single instance of class + PDFGuiControl.""" global _pdfguicontrol if _pdfguicontrol is None: _pdfguicontrol = PDFGuiControl(*args, **kwargs) @@ -555,8 +558,8 @@ def _find_global(moduleName, clsName): class CtrlUnpickler: - """Occasionally the project file may be generated on a platform where - PYTHONPATH is not correctly set up. + """Occasionally the project file may be generated on a platform + where PYTHONPATH is not correctly set up. CtrlUnpickler will transform the module path in the project file to be relative to diffpy so that it can be safely loaded. Only diff --git a/src/diffpy/pdfgui/control/pdflist.py b/src/diffpy/pdfgui/control/pdflist.py index 71bf3e4f..344c1155 100644 --- a/src/diffpy/pdfgui/control/pdflist.py +++ b/src/diffpy/pdfgui/control/pdflist.py @@ -17,8 +17,8 @@ class PDFList(list): - """List class of PDFComponent, which can be accessed through index or a - name string.""" + """List class of PDFComponent, which can be accessed through index + or a name string.""" def __init__(self, *args): """Initialize. diff --git a/src/diffpy/pdfgui/control/pdfstructure.py b/src/diffpy/pdfgui/control/pdfstructure.py index 881e17b2..6dd095ff 100644 --- a/src/diffpy/pdfgui/control/pdfstructure.py +++ b/src/diffpy/pdfgui/control/pdfstructure.py @@ -22,8 +22,8 @@ class PDFStructure(PDFComponent, PDFFitStructure): - """PDFStructure contains structure information, which can be used for 3D - rendering as well as structure refinement.""" + """PDFStructure contains structure information, which can be used + for 3D rendering as well as structure refinement.""" def __init__(self, name, *args, **kwargs): """Initialize PDFStructure. @@ -36,8 +36,8 @@ def __init__(self, name, *args, **kwargs): return def read(self, filename, format="auto"): - """Load structure from a file, raise ControlFileError for invalid or - unknown structure format. + """Load structure from a file, raise ControlFileError for + invalid or unknown structure format. filename -- file to be loaded format -- structure format such as 'pdffit', 'pdb', 'xyz'. When @@ -76,8 +76,9 @@ def copy(self, other=None): _allowed_pdffit_vars = dict.fromkeys(("spdiameter", "stepcut", "delta1", "delta2", "sratio", "rcut")) def setvar(self, var, value): - """Assign to data member using PdfFit-style variable This can be used - when applying constraint equations with particular parameter values. + """Assign to data member using PdfFit-style variable This can be + used when applying constraint equations with particular + parameter values. var -- string representation of PdfFit variable. Possible values: pscale, spdiameter, stepcut, delta1, delta2, sratio, rcut, @@ -128,8 +129,9 @@ def setvar(self, var, value): return def getvar(self, var): - """Obtain value corresponding to PdfFit phase variable var This can be - used when guessing Parameter values from constraints dictionary. + """Obtain value corresponding to PdfFit phase variable var This + can be used when guessing Parameter values from constraints + dictionary. var -- string representation of PdfFit variable. Possible values: pscale, spdiameter, stepcut, delta1, delta2, sratio, rcut, diff --git a/src/diffpy/pdfgui/control/structureviewer.py b/src/diffpy/pdfgui/control/structureviewer.py index 128a2d8f..ad46d5f2 100644 --- a/src/diffpy/pdfgui/control/structureviewer.py +++ b/src/diffpy/pdfgui/control/structureviewer.py @@ -25,7 +25,8 @@ def getStructureViewer(): - """Factory returning singleton instance of the StructureViewer class.""" + """Factory returning singleton instance of the StructureViewer + class.""" global _struviewer if _struviewer is None: _struviewer = StructureViewer() @@ -36,10 +37,11 @@ def getStructureViewer(): class StructureViewer(object): - """Class for plotting structure in general structure viewer. It takes care - of creating temporary structure file in a desired format and launching - structure viewer as a background process. The temporary files are removed - when StructureViewer instance goes out of scope. + """Class for plotting structure in general structure viewer. It + takes care of creating temporary structure file in a desired format + and launching structure viewer as a background process. The + temporary files are removed when StructureViewer instance goes out + of scope. Data attributes: @@ -59,9 +61,9 @@ class StructureViewer(object): """ def __init__(self, executable=None, argstr=None, fileformat=None): - """Create StructureViewer instance. All arguments are optional, they - override defaults described in class docstring. The configuration can - be changed later using setConfig method. + """Create StructureViewer instance. All arguments are optional, + they override defaults described in class docstring. The + configuration can be changed later using setConfig method. executable -- path to the structure viewer executable argstr -- argument string for the viewer program, it can use @@ -97,7 +99,8 @@ def getConfig(self): return rv def setConfig(self, cfg): - """Configure StructureViewer instance using values in a dictionary. + """Configure StructureViewer instance using values in a + dictionary. cfg -- configuration dictionary, with the same keys as returned by getConfig(). Any other keys are ignored. @@ -119,7 +122,8 @@ def getFileFormats(): getFileFormats = staticmethod(getFileFormats) def plot(self, stru): - """Launch new structure viewer and open a temporary copy of stru. + """Launch new structure viewer and open a temporary copy of + stru. stru -- instance of Structure class from diffpy.structure diff --git a/src/diffpy/pdfgui/gui/datasetconfigurepanel.py b/src/diffpy/pdfgui/gui/datasetconfigurepanel.py index cf32dfb6..55c693a3 100644 --- a/src/diffpy/pdfgui/gui/datasetconfigurepanel.py +++ b/src/diffpy/pdfgui/gui/datasetconfigurepanel.py @@ -337,7 +337,8 @@ def setConfigurationData(self): return def restrictConstrainedParameters(self): - """Set 'read-only' boxes that correspond to constrained parameters.""" + """Set 'read-only' boxes that correspond to constrained + parameters.""" if not self.configuration: return diff --git a/src/diffpy/pdfgui/gui/datasetconstraintpanel.py b/src/diffpy/pdfgui/gui/datasetconstraintpanel.py index 267f4664..c585b579 100644 --- a/src/diffpy/pdfgui/gui/datasetconstraintpanel.py +++ b/src/diffpy/pdfgui/gui/datasetconstraintpanel.py @@ -145,7 +145,8 @@ def processFormula(self, value, parname): # EVENT CODE ############################################################# def onSetFocus(self, event): - """Saves a TextCtrl value, to be compared in onKillFocus later.""" + """Saves a TextCtrl value, to be compared in onKillFocus + later.""" self._focusedText = event.GetEventObject().GetValue() event.Skip() return diff --git a/src/diffpy/pdfgui/gui/datasetpanel.py b/src/diffpy/pdfgui/gui/datasetpanel.py index f64cee9e..d49fcf7d 100644 --- a/src/diffpy/pdfgui/gui/datasetpanel.py +++ b/src/diffpy/pdfgui/gui/datasetpanel.py @@ -96,7 +96,8 @@ def refresh(self): return def refreshSelectedPage(self): - """Refresh the panel corresponding to the currently selected page.""" + """Refresh the panel corresponding to the currently selected + page.""" # self.configurePanel.refresh() # self.constraintPanel.refresh() # self.resultsPanel.refresh() diff --git a/src/diffpy/pdfgui/gui/debugoptions.py b/src/diffpy/pdfgui/gui/debugoptions.py index 167d868b..3b5af79e 100644 --- a/src/diffpy/pdfgui/gui/debugoptions.py +++ b/src/diffpy/pdfgui/gui/debugoptions.py @@ -20,9 +20,9 @@ class DebugOptions: - """DebugOptions is a place to store various debugging options. There should - be just one instance defined in pdfguiglobals module. It would be nice to - have a simple way of setting them on command line. + """DebugOptions is a place to store various debugging options. There + should be just one instance defined in pdfguiglobals module. It + would be nice to have a simple way of setting them on command line. Options in short and long forms: noed, noerrordialog -- [False], disable exceptions catching and @@ -59,8 +59,8 @@ def __setattr__(self, name, value): return def __getattr__(self, name): - """Resolve values of short options. This is called only when normal - lookup fails. + """Resolve values of short options. This is called only when + normal lookup fails. returns value of short debug option """ diff --git a/src/diffpy/pdfgui/gui/errorwrapper.py b/src/diffpy/pdfgui/gui/errorwrapper.py index 862849ae..78e0f1cb 100644 --- a/src/diffpy/pdfgui/gui/errorwrapper.py +++ b/src/diffpy/pdfgui/gui/errorwrapper.py @@ -12,8 +12,8 @@ # See LICENSE.txt for license information. # ############################################################################## -"""This module contains a function wrapper and an object wrapper that catch -control errors and shows them in an error report dialog. +"""This module contains a function wrapper and an object wrapper that +catch control errors and shows them in an error report dialog. This is used by PDFPanel and MainFrame. """ @@ -103,7 +103,8 @@ def _f(*args, **kwargs): def catchObjectErrors(obj, exclude=None): - """Wrap all functions of an object so that the exceptions are caught. + """Wrap all functions of an object so that the exceptions are + caught. obj -- Object containing the function. It is assumed that the object has an attribute named 'mainFrame', which is a reference to the MainFrame diff --git a/src/diffpy/pdfgui/gui/extendedplotframe.py b/src/diffpy/pdfgui/gui/extendedplotframe.py index 4cb32cce..9e41fd5e 100644 --- a/src/diffpy/pdfgui/gui/extendedplotframe.py +++ b/src/diffpy/pdfgui/gui/extendedplotframe.py @@ -224,7 +224,8 @@ def removeCurve(self, curveRef): self.__updateViewLimits() def __updateViewLimits(self): - """Adjust the subplot range in order to show all curves correctly.""" + """Adjust the subplot range in order to show all curves + correctly.""" # NOTE: # we need to adjust view limits by ourselves because Matplotlib can't # set the legend nicely when there are multiple curves in the plot. @@ -252,8 +253,8 @@ def __updateViewLimits(self): self.subplot.set_ylim(ymin, ymax) def __translateStyles(self, style): - """Private function to translate general probabilities to Matplotlib - specific ones. + """Private function to translate general probabilities to + Matplotlib specific ones. style -- general curve style dictionary (defined in demoplot) """ @@ -351,7 +352,8 @@ def clear(self): def legendBoxProperties(): - """Legend properties dictionary with keys consistent with MPL version. + """Legend properties dictionary with keys consistent with MPL + version. The argument names have changed in matplotlib 0.98.5. Old arguments do not work with later versions of matplotlib. diff --git a/src/diffpy/pdfgui/gui/fittree.py b/src/diffpy/pdfgui/gui/fittree.py index 1416db92..fd6b5590 100644 --- a/src/diffpy/pdfgui/gui/fittree.py +++ b/src/diffpy/pdfgui/gui/fittree.py @@ -139,7 +139,8 @@ def GetSiblings(self, node): return ids def GetAllType(self, node): - """Get the id of each item in the tree of the same type as node.""" + """Get the id of each item in the tree of the same type as + node.""" nodetype = self.GetNodeType(node) fits = self.GetChildren(self.root) if nodetype == "fit": @@ -617,7 +618,8 @@ def GetClipboard(self): return cdata def PasteBranch(self, entrypoint=None): - """Paste the branch from the clipboard into tree at the given node. + """Paste the branch from the clipboard into tree at the given + node. A certain type of branch can only be copied to specific places. @@ -915,8 +917,8 @@ def __init__(self, *args): # Utility functions def incrementName(name, namelist, start=1): - """Increment the name by assigning the lowest number to the end such that - the name does not appear in the namelist.""" + """Increment the name by assigning the lowest number to the end such + that the name does not appear in the namelist.""" newname = name match = r"\d+$" counter = start diff --git a/src/diffpy/pdfgui/gui/mainframe.py b/src/diffpy/pdfgui/gui/mainframe.py index 79804b06..ab2acbd4 100644 --- a/src/diffpy/pdfgui/gui/mainframe.py +++ b/src/diffpy/pdfgui/gui/mainframe.py @@ -66,14 +66,15 @@ class MainFrame(wx.Frame): - """The left pane is a FitTree (from fittree.py), the right is a dynamic - panel, accessed via the data member rightPanel, which can hold one of any - number of panels. The panels that can appear in the right pane must be - derived from PDFPanel (in pdfpanel.py) and are defined in the dynamicPanels - dictionary, which is defined in __customProperties. A panel is placed in - the right pane by passing its dynamicPanels dictionary key to the - switchRightPanel method. This method takes care of displaying the panel, - giving the data it needs, and calling its refresh() method. + """The left pane is a FitTree (from fittree.py), the right is a + dynamic panel, accessed via the data member rightPanel, which can + hold one of any number of panels. The panels that can appear in the + right pane must be derived from PDFPanel (in pdfpanel.py) and are + defined in the dynamicPanels dictionary, which is defined in + __customProperties. A panel is placed in the right pane by passing + its dynamicPanels dictionary key to the switchRightPanel method. + This method takes care of displaying the panel, giving the data it + needs, and calling its refresh() method. ** NODE TYPES ** The FitTree is essential to the functionality of the Gui. @@ -225,7 +226,8 @@ def __cmdLineLoad(self): return def __defineLocalIds(self): - """Several user functions are duplicated many times throughout the gui. + """Several user functions are duplicated many times throughout + the gui. This occurs mostly between the main menu, the right-click menu, and the many buttons in the gui. This method defines local Ids @@ -1092,7 +1094,8 @@ def checkForSave(self): return code def updateTitle(self): - """Update the title according to the name of the current file.""" + """Update the title according to the name of the current + file.""" shorttitle = os.path.basename(self.fullpath) udirnamed = "~" + os.path.sep udir = os.path.expanduser(udirnamed) @@ -1497,7 +1500,8 @@ def needsSave(self, altered=True): return def disableSharedMenuItems(self, menu): - """Disable some menu items based upon what is selected in the tree. + """Disable some menu items based upon what is selected in the + tree. menu -- The menu which to apply the changes. @@ -1772,7 +1776,8 @@ def onNewFit(self, event): return def onCopy(self, event): - """Copy the subtree of the current selected item into the clipboard.""" + """Copy the subtree of the current selected item into the + clipboard.""" selections = self.treeCtrlMain.GetSelections() if len(selections) == 1: self.treeCtrlMain.CopyBranch(selections[0]) @@ -1916,7 +1921,8 @@ def onDelete(self, event): # Main menu items def onRun(self, event): - """Run the selected fits/calculations and disable their tree entries. + """Run the selected fits/calculations and disable their tree + entries. This also runs calculations that are children of a running fit. """ @@ -2532,7 +2538,8 @@ def onDocumentation(self, event): # MISC INTERACTION ITEMS def showMessage(self, info, title="PDF Control Error"): - """ShowMessage(self, info) --> tell user about an exception and so on. + """ShowMessage(self, info) --> tell user about an exception and + so on. title -- window title info -- message diff --git a/src/diffpy/pdfgui/gui/pdfguiglobals.py b/src/diffpy/pdfgui/gui/pdfguiglobals.py index cae1fa74..5580dca5 100644 --- a/src/diffpy/pdfgui/gui/pdfguiglobals.py +++ b/src/diffpy/pdfgui/gui/pdfguiglobals.py @@ -62,8 +62,8 @@ def iconpath(iconfilename): - """Full path to the icon file in pdfgui installation. This function should - be used whenever GUI needs access to custom icons. + """Full path to the icon file in pdfgui installation. This function + should be used whenever GUI needs access to custom icons. iconfilename -- icon file name without any path diff --git a/src/diffpy/pdfgui/gui/phaseconfigurepanel.py b/src/diffpy/pdfgui/gui/phaseconfigurepanel.py index 96281d5f..db269589 100644 --- a/src/diffpy/pdfgui/gui/phaseconfigurepanel.py +++ b/src/diffpy/pdfgui/gui/phaseconfigurepanel.py @@ -316,7 +316,8 @@ def refresh(self): return def restrictConstrainedParameters(self): - """Set 'read-only' boxes that correspond to constrained parameters.""" + """Set 'read-only' boxes that correspond to constrained + parameters.""" self.setToolTips(tooltips.phasepanel) self.textCtrlA.DefaultStyle.BackgroundColour @@ -452,7 +453,8 @@ def applyCellChange(self, i, j, value): # TextCtrl Events def onSetFocus(self, event): - """Saves a TextCtrl value, to be compared in onKillFocus later.""" + """Saves a TextCtrl value, to be compared in onKillFocus + later.""" self._focusedText = event.GetEventObject().GetValue() event.Skip() return diff --git a/src/diffpy/pdfgui/gui/phaseconstraintspanel.py b/src/diffpy/pdfgui/gui/phaseconstraintspanel.py index 45f37b36..e27ec9b0 100644 --- a/src/diffpy/pdfgui/gui/phaseconstraintspanel.py +++ b/src/diffpy/pdfgui/gui/phaseconstraintspanel.py @@ -416,7 +416,8 @@ def applyCellChange(self, i, j, value): # TextCtrl Events def onSetFocus(self, event): - """Saves a TextCtrl value, to be compared in onKillFocuse later.""" + """Saves a TextCtrl value, to be compared in onKillFocuse + later.""" self._focusedText = event.GetEventObject().GetValue() event.Skip() return diff --git a/src/diffpy/pdfgui/gui/plotpanel.py b/src/diffpy/pdfgui/gui/plotpanel.py index e1ee06dd..c36db091 100644 --- a/src/diffpy/pdfgui/gui/plotpanel.py +++ b/src/diffpy/pdfgui/gui/plotpanel.py @@ -116,8 +116,8 @@ def enableWidgets(self, on=True): return def updateWidgets(self): - """Enable or disable certain widgets depending upon what is selected in - the tree and in the plotting widgets.""" + """Enable or disable certain widgets depending upon what is + selected in the tree and in the plotting widgets.""" # selections: selected nodes in treeCtrl # fits: only different fittings # refs: data item ids ( can be calculation, fit, structure and dataset diff --git a/src/diffpy/pdfgui/gui/resultspanel.py b/src/diffpy/pdfgui/gui/resultspanel.py index f1731aa1..a63256d6 100644 --- a/src/diffpy/pdfgui/gui/resultspanel.py +++ b/src/diffpy/pdfgui/gui/resultspanel.py @@ -85,7 +85,8 @@ def __customProperties(self): # Methods overloaded from PDFPanel def refresh(self): - """Fill in the resultsTextCtrl with the fit results if they exist.""" + """Fill in the resultsTextCtrl with the fit results if they + exist.""" if self.fit: self.results = self.fit.res else: diff --git a/src/diffpy/pdfgui/gui/wxextensions/listctrls.py b/src/diffpy/pdfgui/gui/wxextensions/listctrls.py index b018ae2e..5f693f04 100644 --- a/src/diffpy/pdfgui/gui/wxextensions/listctrls.py +++ b/src/diffpy/pdfgui/gui/wxextensions/listctrls.py @@ -27,7 +27,8 @@ class AutoWidthListCtrl(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin): - """WxListCtrl subclass that automatically adjusts its column width.""" + """WxListCtrl subclass that automatically adjusts its column + width.""" def __init__(self, parent, ID, pos=wx.DefaultPosition, size=wx.DefaultSize, style=0, *args, **kwargs): wx.ListCtrl.__init__(self, parent, ID, pos, size, style, *args, **kwargs) @@ -40,7 +41,8 @@ def clearSelections(self): return def setSelection(self, itemtext=None): - """Convenience function for simple selection of a list item by label. + """Convenience function for simple selection of a list item by + label. itemtext -- The label of the item to select. If itemtext is None (default) then all items will be deselected. @@ -61,8 +63,8 @@ def setSelection(self, itemtext=None): class ColumnSortListCtrl(AutoWidthListCtrl, listmix.ColumnSorterMixin): - """AutoWidthListCtrl subclass that sorts its columns when the column header - is pressed. + """AutoWidthListCtrl subclass that sorts its columns when the column + header is pressed. This ListCtrl requires an itemDataMap member dictionary to be initialized before the sorting capabilities can be realized. This @@ -83,7 +85,8 @@ def GetListCtrl(self): return self def initializeSorter(self): - """Initialize the column sorter mixin after the ListCtrl is filled. + """Initialize the column sorter mixin after the ListCtrl is + filled. This method must be called whenever the itemDataMap is altered. """ @@ -116,8 +119,8 @@ def makeIDM(self): class KeyEventsListCtrl(ColumnSortListCtrl): - """ColumnSortListCtrl that catches key events and selects the item that - matches. + """ColumnSortListCtrl that catches key events and selects the item + that matches. It only searches for items in the first column. """ diff --git a/src/diffpy/pdfgui/gui/wxextensions/paneldialog.py b/src/diffpy/pdfgui/gui/wxextensions/paneldialog.py index 64645e94..4089c224 100644 --- a/src/diffpy/pdfgui/gui/wxextensions/paneldialog.py +++ b/src/diffpy/pdfgui/gui/wxextensions/paneldialog.py @@ -14,8 +14,8 @@ # See LICENSE.txt for license information. # ############################################################################## -"""This module contains the PanelDialog class, a simple class that turns any -panel into a dialog.""" +"""This module contains the PanelDialog class, a simple class that turns +any panel into a dialog.""" import wx diff --git a/src/diffpy/pdfgui/tui.py b/src/diffpy/pdfgui/tui.py index d3404c96..0cb5536d 100644 --- a/src/diffpy/pdfgui/tui.py +++ b/src/diffpy/pdfgui/tui.py @@ -27,7 +27,8 @@ class LoadProject: # public methods def __init__(self, filename=None): - """Initialize LoadProject object, by reading existing project file. + """Initialize LoadProject object, by reading existing project + file. filename -- path to PDFgui project file. """ diff --git a/src/diffpy/pdfgui/utils.py b/src/diffpy/pdfgui/utils.py index fdced9bf..33cdc256 100644 --- a/src/diffpy/pdfgui/utils.py +++ b/src/diffpy/pdfgui/utils.py @@ -19,9 +19,9 @@ def numericStringSort(lst): - """Sort list of strings inplace according to general numeric value. Each - string gets split to string and integer segments to create keys for - comparison. Signs, decimal points and exponents are ignored. + """Sort list of strings inplace according to general numeric value. + Each string gets split to string and integer segments to create keys + for comparison. Signs, decimal points and exponents are ignored. lst -- sorted list of strings @@ -39,9 +39,9 @@ def numericStringSort(lst): def safeCPickleDumps(obj): - """Get pickle representation of an object possibly containing NaN or Inf. - By default it uses pickle.HIGHEST_PROTOCOL, but falls back to ASCII - protocol 0 if there is SystemError frexp() exception. + """Get pickle representation of an object possibly containing NaN or + Inf. By default it uses pickle.HIGHEST_PROTOCOL, but falls back to + ASCII protocol 0 if there is SystemError frexp() exception. obj -- object to be pickled