diff --git a/docs/source/conf.py b/docs/source/conf.py index dc17fe9..aa4fd14 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -69,6 +69,16 @@ # The master toctree document. master_doc = "index" +napoleon_custom_sections = [ + ("Managed Parameters", "Attributes"), + ("Usable Metadata", "Attributes"), + ("General Metadata", "Attributes"), + ("Metadata", "Attributes"), + ("Properties", "Attributes"), + ("Operator Attributes", "Attributes"), + ("Managed ParameterSets", "Attributes"), +] + # General information about the project. project = "diffpy.srfit" copyright = "%Y, The Trustees of Columbia University in the City of New York" diff --git a/news/fix-docs.rst b/news/fix-docs.rst new file mode 100644 index 0000000..77be343 --- /dev/null +++ b/news/fix-docs.rst @@ -0,0 +1,23 @@ +**Added:** + +* No news added: Fix docstrings manually. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/srfit/fitbase/fitcontribution.py b/src/diffpy/srfit/fitbase/fitcontribution.py index dba5f7f..b203cb2 100644 --- a/src/diffpy/srfit/fitbase/fitcontribution.py +++ b/src/diffpy/srfit/fitbase/fitcontribution.py @@ -177,6 +177,7 @@ def addProfileGenerator(self, gen, name=None): A name for the calculator. If name is None (default), then the ProfileGenerator's name attribute will be used. + Raises ValueError if the ProfileGenerator has no name. Raises ValueError if the ProfileGenerator has the same name as some other managed object. @@ -220,6 +221,7 @@ def setEquation(self, eqstr, ns={}): A dictionary of Parameters, indexed by name, that are used in the eqstr, but not registered (default {}). + Raises ValueError if ns uses a name that is already used for a variable. """ @@ -266,6 +268,7 @@ def setResidualEquation(self, eqstr): used, or the chi2 residual will be used if that does not exist. + Two residuals are preset for convenience, "chiv" and "resv". chiv is defined such that dot(chiv, chiv) = chi^2. resv is defined such that dot(resv, resv) = Rw^2. diff --git a/src/diffpy/srfit/fitbase/fitrecipe.py b/src/diffpy/srfit/fitbase/fitrecipe.py index 7c1e335..229d244 100644 --- a/src/diffpy/srfit/fitbase/fitrecipe.py +++ b/src/diffpy/srfit/fitbase/fitrecipe.py @@ -187,6 +187,7 @@ def popFitHook(self, fithook=None, index=-1): index Index of FitHook instance to remove (default -1). + Raises ValueError if fithook is not None, but is not present in the sequence. Raises IndexError if the sequence is empty or index is out of range. @@ -214,6 +215,7 @@ def addContribution(self, con, weight=1.0): con The FitContribution to be stored. + Raises ValueError if the FitContribution has no name Raises ValueError if the FitContribution has the same name as some other managed object. @@ -236,6 +238,7 @@ def addParameterSet(self, parset): parset The ParameterSet to be stored. + Raises ValueError if the ParameterSet has no name. Raises ValueError if the ParameterSet has the same name as some other managed object. @@ -506,7 +509,12 @@ def addVar( A list of tags (default []). Both tag and tags can be applied. - Returns the ParameterProxy (variable) for the passed Parameter. + + Returns + ------- + vars + ParameterProxy (variable) for the passed Parameter. + Raises ValueError if the name of the variable is already taken by another managed object. @@ -549,6 +557,7 @@ def delVar(self, var): var A variable of the FitRecipe. + Raises ValueError if var is not part of the FitRecipe. """ @@ -592,6 +601,7 @@ def newVar(self, name, value=None, fixed=False, tag=None, tags=[]): A list of tags (default []). Both tag and tags can be applied. + Returns the new variable (Parameter instance). """ # This will fix the Parameter @@ -798,6 +808,7 @@ def constrain(self, par, con, ns={}): A dictionary of Parameters, indexed by name, that are used in the eqstr, but not part of this object (default {}). + Raises ValueError if ns uses a name that is already used for a variable. Raises ValueError if eqstr depends on a Parameter that is not part of diff --git a/src/diffpy/srfit/fitbase/fitresults.py b/src/diffpy/srfit/fitbase/fitresults.py index e402bfd..108c2fc 100644 --- a/src/diffpy/srfit/fitbase/fitresults.py +++ b/src/diffpy/srfit/fitbase/fitresults.py @@ -90,6 +90,7 @@ class FitResults(object): The derivatives of the constraint equations with respect to the variables. This is used internally. + Each of these attributes, except the recipe, are created or updated when the update method is called. """ @@ -338,7 +339,10 @@ def formatResults(self, header="", footer="", update=False): update Flag indicating whether to call update() (default False). - Returns a string containing the formatted results. + Returns + ------- + out + a string containing the formatted results. """ if update: self.update() @@ -515,7 +519,7 @@ def formatResults(self, header="", footer="", update=False): def printResults(self, header="", footer="", update=False): """Format and print the results. - Attributes + Parameters ---------- header A header to add to the output (default "") @@ -533,8 +537,10 @@ def __str__(self): def saveResults(self, filename, header="", footer="", update=False): """Format and save the results. - filename - Name of the save file. + Parameters ---------------------------------- + filename + Name of the save file. header A header to add to the output (default "") footer diff --git a/src/diffpy/srfit/fitbase/parameter.py b/src/diffpy/srfit/fitbase/parameter.py index 531a07d..90691e5 100644 --- a/src/diffpy/srfit/fitbase/parameter.py +++ b/src/diffpy/srfit/fitbase/parameter.py @@ -72,6 +72,7 @@ def __init__(self, name, value=None, const=False): A flag inticating whether the Parameter is a constant (like pi). + Raises ValueError if the name is not a valid attribute identifier """ self.constrained = False @@ -94,7 +95,10 @@ def setValue(self, val): The upper bounds for the bounds list. If this is None (default), then the upper bound will not be alterered. - Returns self so that mutators can be chained. + Returns + ------- + self + Returns self so that mutators can be chained. """ Argument.setValue(self, val) return self @@ -112,7 +116,10 @@ def setConst(self, const=True, value=None): is not None, then the parameter will get a new value, constant or otherwise. - Returns self so that mutators can be chained. + Returns + ------- + self + Returns self so that mutators can be chained. """ self.const = bool(const) if value is not None: @@ -129,7 +136,10 @@ def boundRange(self, lb=None, ub=None): ub The upper bound for the bounds list. - Returns self so that mutators can be chained. + Returns + ------- + self + Returns self so that mutators can be chained. """ if lb is not None: self.bounds[0] = lb @@ -150,7 +160,10 @@ def boundWindow(self, lr=0, ur=None): value + ur. If this is None (default), then the value of the lower radius is used. - Returns self so that mutators can be chained. + Returns + ------- + self + Returns self so that mutators can be chained. """ val = self.getValue() lb = val - lr @@ -199,6 +212,7 @@ def __init__(self, name, par): par The Parameter this is a proxy for. + Raises ValueError if the name is not a valid attribute identifier """ validateName(name) @@ -312,6 +326,7 @@ def __init__(self, name, obj, getter=None, setter=None, attr=None): parameter. If attr is None (default), then both getter and setter must be specified. + Raises ValueError if exactly one of getter or setter is not None, or if getter, setter and attr are all None. """ diff --git a/src/diffpy/srfit/fitbase/parameterset.py b/src/diffpy/srfit/fitbase/parameterset.py index 6aafdf7..53edb03 100644 --- a/src/diffpy/srfit/fitbase/parameterset.py +++ b/src/diffpy/srfit/fitbase/parameterset.py @@ -95,6 +95,7 @@ def addParameterSet(self, parset): parset The ParameterSet to be stored. + Raises ValueError if the ParameterSet has no name. Raises ValueError if the ParameterSet has the same name as some other managed object. diff --git a/src/diffpy/srfit/fitbase/profile.py b/src/diffpy/srfit/fitbase/profile.py index 035166e..2600fb8 100644 --- a/src/diffpy/srfit/fitbase/profile.py +++ b/src/diffpy/srfit/fitbase/profile.py @@ -319,7 +319,14 @@ def loadtxt(self, *args, **kw): Raises ValueError if the call to numpy.loadtxt returns fewer than 2 arrays. - Returns the x, y and dy arrays loaded from the file + Returns + ------- + x + x array loaded from the file. + y + y array loaded from the file. + dy + dy array loaded from the file. """ if len(args) == 8 and not args[-1]: args = list(args) @@ -423,9 +430,13 @@ def rebinArray(A, xold, xnew): xnew New sampling array + This uses cubic spline interpolation. - Returns: A new array over the new sampling array. + Returns + ------- + array + A new array over the new sampling array. """ if numpy.array_equal(xold, xnew): return A diff --git a/src/diffpy/srfit/fitbase/profilegenerator.py b/src/diffpy/srfit/fitbase/profilegenerator.py index 9269442..e2b840c 100644 --- a/src/diffpy/srfit/fitbase/profilegenerator.py +++ b/src/diffpy/srfit/fitbase/profilegenerator.py @@ -20,14 +20,23 @@ To define a ProfileGenerator, one must implement the required Parameters and ParameterSets as well as overload the __call__ method with the -calculation. A very simple example is > class -Gaussian(ProfileGenerator): > > def __init__(self): > # -Initialize and give this a name > ProfileGenerator.__init__(self, -"g") > # Add amplitude, center and width parameters > -self.newParameter("amp", 0) > self.newParameter("center", 0) > -self.newParameter("width", 0) > > def __call__(self, x): > a = -self.amp.getValue() > x0 = self.center.getValue() > w = -self.width.getValue() > return a * exp(-0.5*((x-x0)/w)**2) +calculation. A very simple example is + +.. code:: python + + class Gaussian(ProfileGenerator): + def __init__(self): + # Initialize and give this a name + ProfileGenerator.__init__(self, "g") + # Add amplitude, center and width parameters + self.newParameter("amp", 0) + self.newParameter("center", 0) + self.newParameter("width", 0) + def __call__(self, x): + a = self.amp.getValue() + x0 = self.center.getValue() + w = self.width.getValue() + return a * exp(-0.5*((x-x0)/w)**2) More examples can be found in the example directory of the documentation. diff --git a/src/diffpy/srfit/fitbase/profileparser.py b/src/diffpy/srfit/fitbase/profileparser.py index 1f4ef1f..32cb966 100644 --- a/src/diffpy/srfit/fitbase/profileparser.py +++ b/src/diffpy/srfit/fitbase/profileparser.py @@ -29,8 +29,6 @@ class ProfileParser(object): """Class for parsing data from a or string. - Attributes - Attributes ---------- _format @@ -41,20 +39,20 @@ class ProfileParser(object): The data from each bank. Each bank contains a (x, y, dx, dy) tuple: - x - A numpy array containing the independent - variable read from the file. - y - A numpy array containing the profile - from the file. - dx - A numpy array containing the uncertainty in x - read from the file. This is None if the - uncertainty cannot be read. - dy - A numpy array containing the uncertainty read - from the file. This is None if the uncertainty - cannot be read. + x + A numpy array containing the independent + variable read from the file. + y + A numpy array containing the profile + from the file. + dx + A numpy array containing the uncertainty in x + read from the file. This is None if the + uncertainty cannot be read. + dy + A numpy array containing the uncertainty read + from the file. This is None if the uncertainty + cannot be read. _x Independent variable from the chosen bank _y @@ -66,10 +64,9 @@ class ProfileParser(object): _meta A dictionary containing metadata read from the file. - General Metadata - Attributes - ---------- + General Metadata + ---------------- filename The name of the file from which data was parsed. This key will not exist if data was not read from file. diff --git a/src/diffpy/srfit/fitbase/recipeorganizer.py b/src/diffpy/srfit/fitbase/recipeorganizer.py index 1b14d0a..a76593d 100644 --- a/src/diffpy/srfit/fitbase/recipeorganizer.py +++ b/src/diffpy/srfit/fitbase/recipeorganizer.py @@ -250,6 +250,7 @@ def _addObject(self, obj, d, check=True): If True (default), a ValueError is raised an object of the given name already exists. + Raises ValueError if the object has no name. Raises ValueError if the object has the same name as some other managed object. @@ -313,6 +314,7 @@ def _locateManagedObject(self, obj): obj The object to find. + Returns a list of objects. The first member of the list is this object, and each subsequent member is a sub-object of the previous one. The last entry in the list is obj. If obj cannot be found, the list is @@ -402,6 +404,7 @@ class RecipeOrganizer(_recipeorganizer_interface, RecipeContainer): values Variable values (read only). See getValues. + Raises ValueError if the name is not a valid attribute identifier """ @@ -442,6 +445,7 @@ def _addParameter(self, par, check=True): If True (default), a ValueError is raised a Parameter of the specified name has already been inserted. + Raises ValueError if the Parameter has no name. Raises ValueError if the Parameter has the same name as a contained RecipeContainer. @@ -527,10 +531,12 @@ def registerFunction(self, f, name=None, argnames=None): If this is None (default), then the argument names will be extracted from the function. + Note that name and argnames can be extracted from regular python functions (of type 'function'), bound class methods and callable classes. + Raises TypeError if name or argnames cannot be automatically extracted. Raises TypeError if an automatically extracted name is ''. @@ -628,6 +634,7 @@ def registerStringFunction(self, fstr, name, ns={}): used in fstr, but not part of the FitRecipe (default {}). + Raises ValueError if ns uses a name that is already used for another managed object. Raises ValueError if the function name is the name of another managed @@ -660,6 +667,7 @@ def evaluateEquation(self, eqstr, ns={}): A dictionary of Parameters, indexed by name, that are used in fstr, but not part of the FitRecipe (default {}). + Raises ValueError if ns uses a name that is already used for a variable. """ @@ -689,6 +697,7 @@ def constrain(self, par, con, ns={}): A dictionary of Parameters, indexed by name, that are used in the parameter, but not part of this object (default {}). + Raises ValueError if ns uses a name that is already used for a variable. Raises ValueError if par is a string but not part of this object or in @@ -800,6 +809,7 @@ def clearConstraints(self, recurse=False): Recurse into managed objects and clear all constraints found there as well. + This removes constraints that are held in this organizer, no matter where the constrained parameters are from. """ @@ -833,11 +843,13 @@ def restrain(self, res, lb=-inf, ub=inf, sig=1, scaled=False, ns={}): in the equation string, but not part of the RecipeOrganizer (default {}). + The penalty is calculated as (max(0, lb - val, val - ub)/sig)**2 and val is the value of the calculated equation. This is multiplied by the average chi^2 if scaled is True. + Raises ValueError if ns uses a name that is already used for a Parameter. Raises ValueError if res depends on a Parameter that is not part of @@ -1120,6 +1132,7 @@ def equationFromString( Key word dictionary to pass to the argclass constructor (default {}). + Raises ValueError if ns uses a name that is already defined in the factory. Raises ValueError if the equation has undefined parameters. """ diff --git a/src/diffpy/srfit/fitbase/restraint.py b/src/diffpy/srfit/fitbase/restraint.py index f7e68bb..5630d80 100644 --- a/src/diffpy/srfit/fitbase/restraint.py +++ b/src/diffpy/srfit/fitbase/restraint.py @@ -47,6 +47,7 @@ class Restraint(Validatable): the unrestrained point-average chi^2 (chi^2/numpoints) (default False). + The penalty is calculated as (max(0, lb - val, val - ub)/sig)**2 and val is the value of the calculated equation. This is multiplied by the @@ -90,7 +91,10 @@ def penalty(self, w=1.0): The point-average chi^2 which is optionally used to scale the penalty (default 1.0). - Returns the penalty as a float + Returns + ------- + penalty + Returns the penalty as a float """ val = self.eq() penalty = (max(0, self.lb - val, val - self.ub) / self.sig) ** 2 diff --git a/src/diffpy/srfit/fitbase/simplerecipe.py b/src/diffpy/srfit/fitbase/simplerecipe.py index 77b361c..29029f1 100644 --- a/src/diffpy/srfit/fitbase/simplerecipe.py +++ b/src/diffpy/srfit/fitbase/simplerecipe.py @@ -130,6 +130,7 @@ def setObservedProfile(self, xobs, yobs, dyobs=None): dyobs is None (default), it will be set to 1 at each observed xobs. + Raises ValueError if len(yobs) != len(xobs) Raises ValueError if dyobs != None and len(dyobs) != len(xobs) """ @@ -192,7 +193,7 @@ def loadtxt(self, *args, **kw): to by dy. Any other arrays are ignored. These are passed to setObservedProfile. - Raises ValueError if the call to numpy.loadtxt returns fewer + Raises ValueError if the call to numpy.loadtxt returns fewer than 2 arrays. Returns the x, y and dy arrays loaded from the file @@ -217,6 +218,7 @@ def setEquation(self, eqstr, ns={}): A dictionary of Parameters, indexed by name, that are used in the eqstr, but not registered (default {}). + Raises ValueError if ns uses a name that is already used for a variable. """ @@ -254,8 +256,10 @@ def printResults(self, header="", footer=""): def saveResults(self, filename, header="", footer=""): """Format and save the results. - filename - Name of the save file. - ---------------------------------- + Parameters + ---------- + filename + Name of the save file. header A header to add to the output (default "") footer diff --git a/src/diffpy/srfit/pdf/basepdfgenerator.py b/src/diffpy/srfit/pdf/basepdfgenerator.py index ed4b8b9..da867bc 100644 --- a/src/diffpy/srfit/pdf/basepdfgenerator.py +++ b/src/diffpy/srfit/pdf/basepdfgenerator.py @@ -65,10 +65,9 @@ class BasePDFGenerator(ProfileGenerator): Resolution peak broadening term qdamp Resolution peak dampening term - - Managed ParameterSets: - The structure ParameterSet (SrRealParSet instance) used to calculate the - profile is named by the user. + Managed ParameterSets + The structure ParameterSet (SrRealParSet instance) used to + calculate the profile is named by the user. Usable Metadata --------------- diff --git a/src/diffpy/srfit/pdf/characteristicfunctions.py b/src/diffpy/srfit/pdf/characteristicfunctions.py index 97153d0..5d2bf15 100644 --- a/src/diffpy/srfit/pdf/characteristicfunctions.py +++ b/src/diffpy/srfit/pdf/characteristicfunctions.py @@ -54,6 +54,7 @@ def sphericalCF(r, psize): psize The particle diameter + From Kodama et al., Acta Cryst. A, 62, 444-453 (converted from radius to diameter) """ @@ -78,6 +79,7 @@ def spheroidalCF(r, erad, prad): erad equatorial radius + erad < prad equates to a prolate spheroid erad > prad equates to a oblate spheroid erad == prad is a sphere @@ -101,6 +103,7 @@ def spheroidalCF2(r, psize, axrat): axrat The ratio of axis lengths + From Lei et al., Phys. Rev. B, 80, 024118 (2009) """ pelpt = 1.0 * axrat @@ -211,6 +214,7 @@ def lognormalSphericalCF(r, psize, psig): psig The log-normal width of the particle diameter + Here, r is the independent variable, mu is the mean of the distribution (not of the particle size), and s is the width of the distribution. This is the characteristic function for the lognormal distribution of particle @@ -265,6 +269,7 @@ def sheetCF(r, sthick): sthick Thickness of nanosheet + From Kodama et al., Acta Cryst. A, 62, 444-453 """ # handle zero or negative sthick. make it work for scalars and arrays. @@ -294,6 +299,7 @@ def shellCF(r, radius, thickness): thickness Thickness of shell + outer radius = radius + thickness From Lei et al., Phys. Rev. B, 80, 024118 (2009) @@ -315,6 +321,7 @@ def shellCF2(r, a, delta): outer radius = a + thickness/2 + From Lei et al., Phys. Rev. B, 80, 024118 (2009) """ a = 1.0 * a @@ -359,13 +366,12 @@ class SASCF(Calculator): ---------- _model BaseModel object this adapts. - - Managed Parameters: - These depend on the parameters of the BaseModel object held by _model. They - are created from the 'params' attribute of the BaseModel. If a dispersion - is set for the BaseModel, the dispersion "width" will be accessible under - "_width", where is the name a parameter adjusted by - dispersion. + Managed Parameters + These depend on the parameters of the BaseModel object held by _model. + They are created from the 'params' attribute of the BaseModel. If a + dispersion is set for the BaseModel, the dispersion "width" will be + accessible under "_width", where is the name a + parameter adjusted by dispersion. """ def __init__(self, name, model): diff --git a/src/diffpy/srfit/pdf/debyepdfgenerator.py b/src/diffpy/srfit/pdf/debyepdfgenerator.py index 1d182c7..8b35977 100644 --- a/src/diffpy/srfit/pdf/debyepdfgenerator.py +++ b/src/diffpy/srfit/pdf/debyepdfgenerator.py @@ -57,9 +57,9 @@ class DebyePDFGenerator(BasePDFGenerator): qdamp Resolution peak dampening term - Managed ParameterSets: - The structure ParameterSet (SrRealStructure instance) used to calculate the - profile is named by the user. + Managed ParameterSets + The structure ParameterSet (SrRealStructure instance) used to calculate + the profile is named by the user. Usable Metadata --------------- diff --git a/src/diffpy/srfit/pdf/pdfcontribution.py b/src/diffpy/srfit/pdf/pdfcontribution.py index 0304bd0..68bdac8 100644 --- a/src/diffpy/srfit/pdf/pdfcontribution.py +++ b/src/diffpy/srfit/pdf/pdfcontribution.py @@ -201,6 +201,7 @@ def addStructure(self, name, stru, periodic=True): do not support periodicity, in which case this may be ignored. + Returns the new phase (ParameterSet appropriate for what was passed in stru.) """ @@ -245,6 +246,7 @@ def addPhase(self, name, parset, periodic=True): do not support periodicity, in which case this may be ignored. + Returns the new phase (ParameterSet appropriate for what was passed in stru.) """ diff --git a/src/diffpy/srfit/pdf/pdfgenerator.py b/src/diffpy/srfit/pdf/pdfgenerator.py index f78c799..3f30cb0 100644 --- a/src/diffpy/srfit/pdf/pdfgenerator.py +++ b/src/diffpy/srfit/pdf/pdfgenerator.py @@ -56,10 +56,9 @@ class PDFGenerator(BasePDFGenerator): Resolution peak broadening term qdamp Resolution peak dampening term - - Managed ParameterSets: - The structure ParameterSet (SrRealStructure instance) used to calculate the - profile is named by the user. + Managed ParameterSets + The structure ParameterSet (SrRealStructure instance) used to + calculate the profile is named by the user. Usable Metadata --------------- diff --git a/src/diffpy/srfit/pdf/pdfparser.py b/src/diffpy/srfit/pdf/pdfparser.py index 847d7c2..445835f 100644 --- a/src/diffpy/srfit/pdf/pdfparser.py +++ b/src/diffpy/srfit/pdf/pdfparser.py @@ -44,20 +44,20 @@ class PDFParser(ProfileParser): _banks The data from each bank. Each bank contains a (x, y, dx, dy) tuple: - x - A numpy array containing the independent - variable read from the file. - y - A numpy array containing the profile - from the file. - dx - A numpy array containing the uncertainty in x - read from the file. This is 0 if the - uncertainty cannot be read. - dy - A numpy array containing the uncertainty read - from the file. This is 0 if the uncertainty - cannot be read. + x + A numpy array containing the independent + variable read from the file. + y + A numpy array containing the profile + from the file. + dx + A numpy array containing the uncertainty in x + read from the file. This is 0 if the + uncertainty cannot be read. + dy + A numpy array containing the uncertainty read + from the file. This is 0 if the uncertainty + cannot be read. _x Independent variable from the chosen bank _y @@ -81,9 +81,7 @@ class PDFParser(ProfileParser): bank The chosen bank number. - Metadata - These may appear in the metadata dictionary - - Attributes + Metadata ---------- stype The scattering type ("X", "N") @@ -103,6 +101,9 @@ class PDFParser(ProfileParser): Temperature (float) doping Doping (float) + + + These may appear in the metadata dictionary. """ _format = "PDF" diff --git a/src/diffpy/srfit/sas/sasgenerator.py b/src/diffpy/srfit/sas/sasgenerator.py index 64b781f..238ae43 100644 --- a/src/diffpy/srfit/sas/sasgenerator.py +++ b/src/diffpy/srfit/sas/sasgenerator.py @@ -32,12 +32,12 @@ class SASGenerator(ProfileGenerator): _model BaseModel object this adapts. - Managed Parameters: - These depend on the parameters of the BaseModel object held by _model. They - are created from the 'params' attribute of the BaseModel. If a dispersion - is set for the BaseModel, the dispersion "width" will be accessible under - "_width", where is the name a parameter adjusted by - dispersion. + Managed Parameters + These depend on the parameters of the BaseModel object held by _model. + They are created from the 'params' attribute of the BaseModel. If a + dispersion is set for the BaseModel, the dispersion "width" will be + accessible under "_width", where is the name a + parameter adjusted by dispersion. """ def __init__(self, name, model): diff --git a/src/diffpy/srfit/sas/sasparser.py b/src/diffpy/srfit/sas/sasparser.py index 70a5b33..1ddd48b 100644 --- a/src/diffpy/srfit/sas/sasparser.py +++ b/src/diffpy/srfit/sas/sasparser.py @@ -41,20 +41,21 @@ class SASParser(ProfileParser): _banks The data from each bank. Each bank contains a (x, y, dx, dy) tuple: - x - A numpy array containing the independent - variable read from the file. - y - A numpy array containing the profile - from the file. - dx - A numpy array containing the uncertainty in x - read from the file. This is 0 if the - uncertainty cannot be read. - dy - A numpy array containing the uncertainty read - from the file. This is 0 if the uncertainty - cannot be read. + + x + A numpy array containing the independent + variable read from the file. + y + A numpy array containing the profile + from the file. + dx + A numpy array containing the uncertainty in x + read from the file. This is 0 if the + uncertainty cannot be read. + dy + A numpy array containing the uncertainty read + from the file. This is 0 if the uncertainty + cannot be read. _x Independent variable from the chosen bank _y @@ -66,10 +67,9 @@ class SASParser(ProfileParser): _meta A dictionary containing metadata read from the file. - General Metadata - Attributes - ---------- + General Metadata + ---------------- filename The name of the file from which data was parsed. This key will not exist if data was not read from file. @@ -78,12 +78,14 @@ class SASParser(ProfileParser): bank The chosen bank number. - Metadata - These may appear in the metadata dictionary - Attributes - ---------- + Metadata + -------- datainfo The DataInfo object used to do the data parsing. + + + These may appear in the metadata dictionary """ _format = "SAS" diff --git a/src/diffpy/srfit/structure/objcrystparset.py b/src/diffpy/srfit/structure/objcrystparset.py index b734542..dec7917 100644 --- a/src/diffpy/srfit/structure/objcrystparset.py +++ b/src/diffpy/srfit/structure/objcrystparset.py @@ -212,6 +212,7 @@ class ObjCrystMoleculeParSet(ObjCrystScattererParSet): (ParameterAdapter) q0, q1, q2, q3 -- Orientational quaternion (ParameterAdapter) + Other attributes are inherited from diffpy.srfit.fitbase.parameterset.ParameterSet """ @@ -418,7 +419,8 @@ def restrainBondLength( Returns ------- - The ObjCrystBondLengthRestraint object for use with the + res + The ObjCrystBondLengthRestraint object for use with the 'unrestrain' method. """ res = ObjCrystBondLengthRestraint( @@ -451,8 +453,11 @@ def restrainBondLengthParameter( by the unrestrained point-average chi^2 (chi^2/numpoints) (default False) - Returns the ObjCrystBondLengthRestraint object for use with the - 'unrestrain' method. + Returns + ------- + ObjCrystBondLengthRestraint object + Returns the ObjCrystBondLengthRestraint object for use with the + 'unrestrain' method. """ return self.restrainBondLength( par.atom1, par.atom2, length, sigma, delta, scaled @@ -486,8 +491,11 @@ def restrainBondAngle( by the unrestrained point-average chi^2 (chi^2/numpoints) (default False). - Returns the ObjCrystBondAngleRestraint object for use with the - 'unrestrain' method. + Returns + ------- + ObjCrystBondAngleRestraint object + Returns the ObjCrystBondAngleRestraint object for use with the + 'unrestrain' method. """ res = ObjCrystBondAngleRestraint( atom1, atom2, atom3, angle, sigma, delta, scaled @@ -519,8 +527,11 @@ def restrainBondAngleParameter( by the unrestrained point-average chi^2 (chi^2/numpoints) (default False). - Returns the ObjCrystBondAngleRestraint object for use with the - 'unrestrain' method. + Returns + ------- + ObjCrystBondAngleRestraint object + Returns the ObjCrystBondAngleRestraint object for use with the + 'unrestrain' method. """ return self.restrainBondAngle( par.atom1, par.atom2, par.atom3, angle, sigma, delta, scaled @@ -555,8 +566,11 @@ def restrainDihedralAngle( by the unrestrained point-average chi^2 (chi^2/numpoints) (default False). - Returns the ObjCrystDihedralAngleRestraint object for use with the - 'unrestrain' method. + Returns + ------- + ObjCrystDihedralAngleRestraint object + Returns the ObjCrystDihedralAngleRestraint object for use with the + 'unrestrain' method. """ res = ObjCrystDihedralAngleRestraint( atom1, atom2, atom3, atom4, angle, sigma, delta, scaled @@ -589,8 +603,11 @@ def restrainDihedralAngleParameter( by the unrestrained point-average chi^2 (chi^2/numpoints) (default False). - Returns the ObjCrystDihedralAngleRestraint object for use with the - 'unrestrain' method. + Returns + ------- + ObjCrystDihedralAngleRestraint object + Returns the ObjCrystDihedralAngleRestraint object for use with the + 'unrestrain' method. """ return self.restrainDihedralAngle( par.atom1, @@ -628,7 +645,10 @@ def addBondLengthParameter( A flag indicating whether the Parameter is constant (default False) - Returns the new ObjCrystBondLengthParameter. + Returns + ------- + ObjCrystBondLengthParameter object + Returns the new ObjCrystBondLengthParameter. """ par = ObjCrystBondLengthParameter(name, atom1, atom2, value, const) self.addParameter(par) @@ -663,7 +683,10 @@ def addBondAngleParameter( A flag indicating whether the Parameter is constant (default False). - Returns the new ObjCrystBondAngleParameter. + Returns + ------- + ObjCrystBondAngleParameter object + Returns the new ObjCrystBondAngleParameter. """ par = ObjCrystBondAngleParameter( name, atom1, atom2, atom3, value, const @@ -704,7 +727,10 @@ def addDihedralAngleParameter( A flag indicating whether the Parameter is constant (default False). - Returns the new ObjCrystDihedralAngleParameter. + Returns + ------- + ObjCrystDihedralAngleParameter object + Returns the new ObjCrystDihedralAngleParameter. """ par = ObjCrystDihedralAngleParameter( name, atom1, atom2, atom3, atom4, value, const diff --git a/src/diffpy/srfit/structure/sgconstraints.py b/src/diffpy/srfit/structure/sgconstraints.py index 72df87c..ad3ba0e 100644 --- a/src/diffpy/srfit/structure/sgconstraints.py +++ b/src/diffpy/srfit/structure/sgconstraints.py @@ -69,6 +69,7 @@ def constrainAsSpaceGroup( Symbol for isotropic ADP (default "Uiso"). If None, isotropic ADPs will be constrained via the anisotropic ADPs. + New Parameters that are used in constraints are created within a SpaceGroupParameters object, which is returned from this function. Constraints are created in ParameterSet that contains the constrained @@ -78,29 +79,28 @@ def constrainAsSpaceGroup( The lattice constraints are applied as following. Crystal System - -------------- - Triclinic - No constraints. - Monoclinic - alpha and beta are fixed to 90 unless alpha != beta and - alpha == gamma, in which case alpha and gamma are fixed - to 90. - Orthorhombic - alpha, beta and gamma are fixed to 90. - Tetragonal - b is constrained to a and alpha, beta and gamma are - fixed to 90. - Trigonal - If gamma == 120, then b is constrained to a, alpha - and beta are fixed to 90 and gamma is fixed to 120. - Otherwise, b and c are constrained to a, beta and gamma - are fixed to alpha. - Hexagonal - b is constrained to a, alpha and beta are fixed to 90 - and gamma is fixed to 120. - Cubic - b and c are constrained to a, and alpha, beta and - gamma are fixed to 90. + Triclinic + No constraints. + Monoclinic + alpha and beta are fixed to 90 unless alpha != beta and + alpha == gamma, in which case alpha and gamma are fixed + to 90. + Orthorhombic + alpha, beta and gamma are fixed to 90. + Tetragonal + b is constrained to a and alpha, beta and gamma are + fixed to 90. + Trigonal + If gamma == 120, then b is constrained to a, alpha + and beta are fixed to 90 and gamma is fixed to 120. + Otherwise, b and c are constrained to a, beta and gamma + are fixed to alpha. + Hexagonal + b is constrained to a, alpha and beta are fixed to 90 + and gamma is fixed to 120. + Cubic + b and c are constrained to a, and alpha, beta and + gamma are fixed to 90. """ from diffpy.structure.spacegroups import GetSpaceGroup, SpaceGroup @@ -783,7 +783,10 @@ def _makeconstraint(parname, formula, scatterer, idx, ns={}): ns namespace to draw extra names from (default {}) - Returns the parameter if it is free. + Returns + ------- + par + Returns the parameter if it is free. """ par = scatterer.get(parname) diff --git a/src/diffpy/srfit/util/inpututils.py b/src/diffpy/srfit/util/inpututils.py index 0f9e00f..b5dfa2a 100644 --- a/src/diffpy/srfit/util/inpututils.py +++ b/src/diffpy/srfit/util/inpututils.py @@ -31,6 +31,7 @@ def inputToString(input): An open file-like object, name of a file or a string containing the input. + Returns the input in a string Raises IOError if the input is supected to be a file name, but the file cannot be found. diff --git a/src/diffpy/srfit/util/tagmanager.py b/src/diffpy/srfit/util/tagmanager.py index 76b99ee..6e78042 100644 --- a/src/diffpy/srfit/util/tagmanager.py +++ b/src/diffpy/srfit/util/tagmanager.py @@ -60,6 +60,7 @@ def tag(self, obj, *tags): *tags Tags to apply to obj. + Raises TypeError if obj is not hashable. """ for tag in tags: @@ -78,6 +79,7 @@ def untag(self, obj, *tags): Tags to remove from obj. If this is empty, then all tags will be removed from obj. + Raises KeyError if a passed tag does not apply to obj and self.silent is False """