From 7dd69bc61db25b004e5d623df39864a755bb813d Mon Sep 17 00:00:00 2001 From: Rundong Hua <157993340+stevenhua0320@users.noreply.github.com> Date: Wed, 31 Jul 2024 02:08:50 +0800 Subject: [PATCH 1/3] lint check, fix break import modules, remove unused import modules, remove some # (#33) --- diffpy/srmise/applications/extract.py | 34 +++++++++-------------- diffpy/srmise/modelevaluators/aic.py | 13 +++++---- diffpy/srmise/pdfpeakextraction.py | 16 +++++++---- diffpy/srmise/peaks/__init__.py | 5 ---- diffpy/srmise/peaks/base.py | 10 +++---- diffpy/srmise/peaks/terminationripples.py | 1 - diffpy/srmise/srmiselog.py | 13 ++++----- doc/examples/extract_single_peak.py | 20 ++++++------- 8 files changed, 50 insertions(+), 62 deletions(-) diff --git a/diffpy/srmise/applications/extract.py b/diffpy/srmise/applications/extract.py index 5f54118..c070704 100755 --- a/diffpy/srmise/applications/extract.py +++ b/diffpy/srmise/applications/extract.py @@ -419,25 +419,19 @@ def main(): from diffpy.srmise.pdfpeakextraction import PDFPeakExtraction from diffpy.srmise.srmiseerrors import SrMiseDataFormatError, SrMiseFileError - if options.peakfunction is not None: - from diffpy.srmise import peaks - - try: - options.peakfunction = eval("peaks." + options.peakfunction) - except Exception as err: - print(err) - print("Could not create peak function '%s'. Exiting." % options.peakfunction) - return - - if options.modelevaluator is not None: - from diffpy.srmise import modelevaluators - - try: - options.modelevaluator = eval("modelevaluators." + options.modelevaluator) - except Exception as err: - print(err) - print("Could not find ModelEvaluator '%s'. Exiting." % options.modelevaluator) - return + try: + options.peakfunction = eval("peaks." + options.peakfunction) + except Exception as err: + print(err) + print("Could not create peak function '%s'. Exiting." % options.peakfunction) + return + + try: + options.modelevaluator = eval("modelevaluators." + options.modelevaluator) + except Exception as err: + print(err) + print("Could not find ModelEvaluator '%s'. Exiting." % options.modelevaluator) + return if options.bcrystal is not None: from diffpy.srmise.baselines import Polynomial @@ -475,8 +469,6 @@ def main(): bl = NanoSpherical() options.baseline = parsepars(bl, options.bspherical) - elif options.baseline is not None: - from diffpy.srmise import baselines try: options.baseline = eval("baselines." + options.baseline) diff --git a/diffpy/srmise/modelevaluators/aic.py b/diffpy/srmise/modelevaluators/aic.py index 7321d9f..a8d870b 100644 --- a/diffpy/srmise/modelevaluators/aic.py +++ b/diffpy/srmise/modelevaluators/aic.py @@ -16,7 +16,6 @@ import numpy as np -import diffpy.srmise.srmiselog from diffpy.srmise.modelevaluators.base import ModelEvaluator from diffpy.srmise.srmiseerrors import SrMiseModelEvaluatorError @@ -72,7 +71,7 @@ def evaluate(self, fit, count_fixed=False, kshift=0): logger.warn("AIC.evaluate(): too few data to evaluate quality reliably.") n = self.minpoints(k) - if self.chisq == None: + if self.chisq is None: self.chisq = self.chi_squared(fit.value(), fit.y_cluster, fit.error_cluster) self.stat = self.chisq + self.parpenalty(k, n) @@ -94,10 +93,12 @@ def parpenalty(self, k, n): return (2 * k) * fudgefactor def growth_justified(self, fit, k_prime): - """Returns whether adding k_prime parameters to the given model (ModelCluster) is justified given the current quality of the fit. - The assumption is that adding k_prime parameters will result in "effectively 0" chiSquared cost, and so adding it is justified - if the cost of adding these parameters is less than the current chiSquared cost. The validity of this assumption (which - depends on an unknown chiSquared value) and the impact of the errors used should be examined more thoroughly in the future. + """Returns whether adding k_prime parameters to the given model (ModelCluster) is justified + given the current quality of the fit. The assumption is that adding k_prime parameters will + result in "effectively 0" chiSquared cost, and so adding it is justified if the cost of adding + these parameters is less than the current chiSquared cost. + The validity of this assumption (which depends on an unknown chiSquared value) + and the impact of the errors used should be examined more thoroughly in the future. """ if self.chisq is None: diff --git a/diffpy/srmise/pdfpeakextraction.py b/diffpy/srmise/pdfpeakextraction.py index f68a7cf..ab5f03d 100644 --- a/diffpy/srmise/pdfpeakextraction.py +++ b/diffpy/srmise/pdfpeakextraction.py @@ -16,20 +16,24 @@ import os.path import re -import matplotlib.pyplot as plt import numpy as np +from diffpy.srmise import srmiselog from diffpy.srmise.modelcluster import ModelCluster, ModelCovariance # from diffpy.pdfgui.control.pdfdataset import PDFDataSet from diffpy.srmise.pdfdataset import PDFDataSet from diffpy.srmise.peakextraction import PeakExtraction -from diffpy.srmise.srmiseerrors import * +from diffpy.srmise.srmiseerrors import ( + SrMiseDataFormatError, + SrMiseError, + SrMiseQmaxError, + SrMiseStaticOwnerError, + SrMiseUndefinedCovarianceError, +) logger = logging.getLogger("diffpy.srmise") -from diffpy.srmise import srmiselog - class PDFPeakExtraction(PeakExtraction): """Class for peak extraction of peaks from the PDF. @@ -454,7 +458,7 @@ def extract(self, **kwds): try: logger.info(str(cov)) # logger.info("Correlations > .8:\n%s", "\n".join(str(c) for c in cov.correlationwarning(.8))) - except SrMiseUndefinedCovarianceError as e: + except SrMiseUndefinedCovarianceError: logger.warn("Covariance not defined for final model. Fit may not have converged.") logger.info(str(ext)) @@ -527,7 +531,7 @@ def fit(self, **kwds): logger.info(str(ext)) try: logger.info(str(cov)) - except SrMiseUndefinedCovarianceError as e: + except SrMiseUndefinedCovarianceError: logger.warn("Covariance not defined for final model. Fit may not have converged.") # Update calculated instance variables diff --git a/diffpy/srmise/peaks/__init__.py b/diffpy/srmise/peaks/__init__.py index dba8fb9..ea3cdfc 100644 --- a/diffpy/srmise/peaks/__init__.py +++ b/diffpy/srmise/peaks/__init__.py @@ -13,8 +13,3 @@ ############################################################################## __all__ = ["base", "gaussian", "gaussianoverr", "terminationripples"] - -from base import Peak, Peaks -from gaussian import Gaussian -from gaussianoverr import GaussianOverR -from terminationripples import TerminationRipples diff --git a/diffpy/srmise/peaks/base.py b/diffpy/srmise/peaks/base.py index ddd6095..47e7a78 100644 --- a/diffpy/srmise/peaks/base.py +++ b/diffpy/srmise/peaks/base.py @@ -16,10 +16,9 @@ import numpy as np -import diffpy.srmise.srmiselog from diffpy.srmise.basefunction import BaseFunction from diffpy.srmise.modelparts import ModelPart, ModelParts -from diffpy.srmise.srmiseerrors import * +from diffpy.srmise.srmiseerrors import SrMiseDataFormatError, SrMiseScalingError logger = logging.getLogger("diffpy.srmise") @@ -263,17 +262,16 @@ def factory(peakstr, ownerlist): peakstr: string representing peak ownerlist: List of BaseFunctions that owner is in """ - from numpy import array data = peakstr.strip().splitlines() # dictionary of parameters pdict = {} for d in data: - l = d.split("=", 1) - if len(l) == 2: + parse_value = d.split("=", 1) + if len(parse_value) == 2: try: - pdict[l[0]] = eval(l[1]) + pdict[parse_value[0]] = eval(parse_value[1]) except Exception: emsg = "Invalid parameter: %s" % d raise SrMiseDataFormatError(emsg) diff --git a/diffpy/srmise/peaks/terminationripples.py b/diffpy/srmise/peaks/terminationripples.py index 7c4785a..f916d3b 100644 --- a/diffpy/srmise/peaks/terminationripples.py +++ b/diffpy/srmise/peaks/terminationripples.py @@ -281,7 +281,6 @@ def extend_grid(self, r, dr): from diffpy.srmise.modelevaluators import AICc from diffpy.srmise.peaks import Peaks from diffpy.srmise.peaks.gaussianoverr import GaussianOverR - from diffpy.srmise.peaks.terminationripples import TerminationRipples res = 0.01 r = np.arange(2, 4, res) diff --git a/diffpy/srmise/srmiselog.py b/diffpy/srmise/srmiselog.py index bfc6002..361ea4b 100644 --- a/diffpy/srmise/srmiselog.py +++ b/diffpy/srmise/srmiselog.py @@ -41,11 +41,10 @@ import logging import os.path import re -import sys from diffpy.srmise.srmiseerrors import SrMiseDataFormatError, SrMiseFileError, SrMiseLogError -### Default settings ### +# Default settings ### defaultformat = "%(message)s" defaultlevel = logging.INFO @@ -57,7 +56,7 @@ "critical": logging.CRITICAL, } -### Set up logging to stdout ### +# Set up logging to stdout ### logger = logging.getLogger("diffpy.srmise") logger.setLevel(defaultlevel) ch = logging.StreamHandler() @@ -68,10 +67,10 @@ logger.addHandler(ch) -### Optional file logger ### +# Optional file logger ### fh = None -### Make updated plots as fitting progresses. ### +# Make updated plots as fitting progresses. ### liveplots = False wait = False @@ -144,7 +143,7 @@ def liveplotting(lp, w=False): raise ValueError(emsg) -### TracePeaks. Primary purpose is to enable creating movies. ### +# TracePeaks. Primary purpose is to enable creating movies. ### class TracePeaks(object): @@ -345,7 +344,7 @@ def getfilter(self): filter = property(getfilter, setfilter) -### End of class TracePeaks +# End of class TracePeaks def settracer(**kwds): diff --git a/doc/examples/extract_single_peak.py b/doc/examples/extract_single_peak.py index 99edd4c..b32b0be 100644 --- a/doc/examples/extract_single_peak.py +++ b/doc/examples/extract_single_peak.py @@ -27,26 +27,26 @@ import matplotlib.pyplot as plt -from diffpy.srmise import PDFPeakExtraction from diffpy.srmise.applications.plot import makeplot from diffpy.srmise.baselines import Polynomial +from diffpy.srmise.pdfpeakextraction import PDFPeakExtraction def run(plot=True): - ## Initialize peak extraction + # Initialize peak extraction # Create peak extraction object ppe = PDFPeakExtraction() # Load the PDF from a file ppe.loadpdf("data/Ag_nyquist_qmax30.gr") - ## Set up extraction parameters. - # For convenience we add all parameters to a dictionary before passing them + # Set up extraction parameters. + # For convenience, we add all parameters to a dictionary before passing them # to the extraction object. # # The "rng" (range) parameter defines the region over which peaks will be - # extracted and fit. For the well isolated nearest-neighbor silver peak, + # extracted and fit. For the well isolated nearest-neighbor silver peak, # which occurs near 2.9 angstroms, it is sufficient to perform extraction # between 2 and 3.5 angstroms. # @@ -61,24 +61,24 @@ def run(plot=True): # Apply peak extraction parameters. ppe.setvars(**kwds) - ## Perform peak extraction + # Perform peak extraction ppe.extract() - ## Save output + # Save output # The write() method saves a file which preserves all aspects of peak # extraction and its results, by convention using the .srmise extension, # and which can later be read by diffpy.srmise. # # The writepwa() method saves a file intended as a human-readable summary. # In particular, it reports the position, width (as full-width at - # half-maximum), and area of of extracted peaks. The reported values + # half-maximum), and area of extracted peaks. The reported values # are for Gaussians in the radial distribution function (RDF) corresponding # to this PDF. ppe.write("output/extract_single_peak.srmise") ppe.writepwa("output/extract_single_peak.pwa") - ## Plot results. - # Display plot of extracted peak. It is also possible to plot an existing + # Plot results. + # Display plot of extracted peak. It is also possible to plot an existing # .srmise file from the command line using # srmise output/Ag_singlepeak.srmise --no-extract --plot # For additional plotting options, run "srmiseplot --help". From 81b261bfa3d21795b209b6be518acf4306f9e2a4 Mon Sep 17 00:00:00 2001 From: Rundong Hua <157993340+stevenhua0320@users.noreply.github.com> Date: Wed, 31 Jul 2024 02:12:05 +0800 Subject: [PATCH 2/3] fix break import modules, remove unused import modules, fix docstring length (#34) --- diffpy/srmise/multimodelselection.py | 55 +++++++++++++--------------- diffpy/srmise/pdfdataset.py | 1 - 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/diffpy/srmise/multimodelselection.py b/diffpy/srmise/multimodelselection.py index 4c1ffa6..3fc4f5b 100644 --- a/diffpy/srmise/multimodelselection.py +++ b/diffpy/srmise/multimodelselection.py @@ -18,9 +18,8 @@ import numpy as np from matplotlib import transforms -import diffpy.srmise.srmiselog -from diffpy.srmise import ModelCluster, PeakStability -from diffpy.srmise.modelevaluators.base import ModelEvaluator +from diffpy.srmise.modelcluster import ModelCluster +from diffpy.srmise.peakstability import PeakStability logger = logging.getLogger("diffpy.srmise") @@ -114,7 +113,7 @@ def makeaics(self, dgs, dr, filename=None): if filename is not None: try: import cPickle as pickle - except: + except ImportError: import pickle out_s = open(filename, "wb") pickle.dump(aics_out, out_s) @@ -126,7 +125,7 @@ def loadaics(self, filename): """Load file containing results of the testall method.""" try: import cPickle as pickle - except: + except ImportError: import pickle in_s = open(filename, "rb") aics_in = pickle.load(in_s) @@ -321,7 +320,7 @@ def classify(self, r, tolerance=0.05): exemplar_baseline = self.results[classes[c][0]][2] # Check baseline type and number of parameters - if type(baseline) != type(exemplar_baseline): + if type(baseline) is not type(exemplar_baseline): continue if baseline.npars() != exemplar_baseline.npars(): continue @@ -331,7 +330,7 @@ def classify(self, r, tolerance=0.05): if len(peaks) != len(exemplar_peaks): continue for p, ep in zip(peaks, exemplar_peaks): - if type(p) != type(ep): + if type(p) is not type(ep): badpeak = True break if p.npars() != ep.npars(): @@ -341,7 +340,6 @@ def classify(self, r, tolerance=0.05): continue # check peak values - current_psqval = [] for p, ep in zip(psqval, epsqval[c]): basediff = np.abs(np.sum(p - ep)) # if basediff > tolerance*np.sum(ep): @@ -383,7 +381,6 @@ def classify(self, r, tolerance=0.05): def makesortedclasses(self): self.sortedclasses = {} - em = self.ppe.error_method for dg in self.dgs: bestinclass = [] @@ -468,13 +465,15 @@ def plot3dclassprobs(self, **kwds): dGs - Sequence of dG values to plot. Default is all values. highlight - Sequence of dG values to highlight on plot. Default is []. classes - Sequence of indices of classes to plot. Default is all classes. - probfilter - [float1, float2]. Only show classes with maximum probability in given range. Default is [0., 1.] + probfilter - [float1, float2]. Only show classes with maximum probability in given range. + Default is [0., 1.] class_size - Report the size of each class as a "number" or "fraction". Default is "number". norm - A colors normalization for displaying number/fraction of models in class. Default is "auto". If equal to "full" determined by the total number of models. If equal to "auto" determined by the number of models in displayed classes. - cmap - A colormap or registered colormap name. Default is cm.jet. If class_size is "number" and norm is either "auto" - or "full" the map is converted to an indexed colormap. + cmap - A colormap or registered colormap name. Default is cm.jet. + If class_size is "number" and norm is either "auto" + or "full" the map is converted to an indexed colormap. highlight_cmap - A colormap or registered colormap name for coloring highlights. Default is cm.gray. title - True, False, or a string. Defaults to True, which displays some basic information about the graph. p_alpha - Probability graph alpha. (Colorbar remains opaque). Default is 0.7. @@ -495,12 +494,11 @@ def plot3dclassprobs(self, **kwds): from matplotlib import cm, colorbar, colors from matplotlib.collections import PolyCollection - from mpl_toolkits.mplot3d import Axes3D fig = kwds.pop("figure", plt.gcf()) ax = fig.add_subplot(kwds.pop("subplot", 111), projection="3d") - cbkwds = kwds.copy() + kwds.copy() # Resolve keywords (title resolved later) dGs = kwds.pop("dGs", self.dgs) @@ -530,41 +528,41 @@ def plot3dclassprobs(self, **kwds): # Define face colors fc = np.array([len(self.classes[z]) for z in zlabels]) - if class_size is "fraction": + if class_size == "fraction": fc = fc / float(len(self.results)) # Index the colormap if necessary - if class_size is "number": - if norm is "auto": + if class_size == "number": + if norm == "auto": indexedcolors = cmap(np.linspace(0.0, 1.0, np.max(fc))) cmap = colors.ListedColormap(indexedcolors) - elif norm is "full": + elif norm == "full": indexedcolors = cmap(np.linspace(0.0, 1.0, len(self.results))) cmap = colors.ListedColormap(indexedcolors) # A user-specified norm cannot be used to index a colormap. # Create proper norms for "auto" and "full" types. - if norm is "auto": - if class_size is "number": + if norm == "auto": + if class_size == "number": mic = np.min(fc) mac = np.max(fc) nc = mac - mic + 1 norm = colors.BoundaryNorm(np.linspace(mic, mac + 1, nc + 1), nc) - if class_size is "fraction": + if class_size == "fraction": norm = colors.Normalize() norm.autoscale(fc) - elif norm is "full": + elif norm == "full": mcolor = len(self.results) - if class_size is "number": + if class_size == "number": norm = colors.BoundaryNorm(np.linspace(0, mcolor + 1, mcolor + 2), mcolor + 1) - if class_size is "fraction": + if class_size == "fraction": norm = colors.Normalize(0.0, 1.0) zs = np.arange(len(zlabels)) poly = PolyCollection(verts, facecolors=cmap(norm(fc)), closed=False) poly.set_alpha(p_alpha) - cax = ax.add_collection3d(poly, zs=zs, zdir="y") + ax.add_collection3d(poly, zs=zs, zdir="y") # Highlight values of interest color_idx = np.linspace(0, 1, len(highlight)) @@ -602,12 +600,11 @@ def plot3dclassprobs(self, **kwds): ) if title is not False: - figtitle = fig.suptitle(title) + fig.suptitle(title) # Add colorbar if "cbpos" in kwds: cbpos = kwds.pop("cbpos") - aspect = cbpos[3] / cbpos[2] plt.tight_layout() # do it before cbaxis, so colorbar is ignored. transAtoF = ax.transAxes + fig.transFigure.inverted() rect = transforms.Bbox.from_bounds(*cbpos).transformed(transAtoF).bounds @@ -626,9 +623,9 @@ def plot3dclassprobs(self, **kwds): cb = colorbar.ColorbarBase(cbaxis, cmap=cmap, norm=norm, **kwds) - if class_size is "number": + if class_size == "number": cb.set_label("Models in class") - elif class_size is "fraction": + elif class_size == "fraction": cb.set_label("Fraction of models in class") return {"fig": fig, "axis": ax, "cb": cb, "cbaxis": cbaxis} diff --git a/diffpy/srmise/pdfdataset.py b/diffpy/srmise/pdfdataset.py index 034a93d..8671e28 100644 --- a/diffpy/srmise/pdfdataset.py +++ b/diffpy/srmise/pdfdataset.py @@ -20,7 +20,6 @@ """ -import copy import os.path import re import time From 978dca163b9920eea63b0cf148e5934f48a649ce Mon Sep 17 00:00:00 2001 From: Rundong Hua <157993340+stevenhua0320@users.noreply.github.com> Date: Wed, 31 Jul 2024 02:16:07 +0800 Subject: [PATCH 3/3] fix formatting issue and typo in copyright (#35) --- diffpy/srmise/basefunction.py | 3 +-- diffpy/srmise/baselines/arbitrary.py | 14 +++++++------- diffpy/srmise/baselines/base.py | 2 +- diffpy/srmise/baselines/fromsequence.py | 2 +- diffpy/srmise/baselines/nanospherical.py | 4 ++-- diffpy/srmise/baselines/polynomial.py | 10 ++++------ diffpy/srmise/dataclusters.py | 2 +- diffpy/srmise/modelcluster.py | 2 +- diffpy/srmise/modelevaluators/aic.py | 2 +- diffpy/srmise/modelevaluators/aicc.py | 2 +- diffpy/srmise/modelevaluators/base.py | 2 +- diffpy/srmise/peaks/base.py | 2 +- diffpy/srmise/peaks/gaussian.py | 2 +- diffpy/srmise/peaks/gaussianoverr.py | 2 +- diffpy/srmise/peaks/terminationripples.py | 2 +- 15 files changed, 25 insertions(+), 28 deletions(-) diff --git a/diffpy/srmise/basefunction.py b/diffpy/srmise/basefunction.py index d0049a5..d5dd220 100644 --- a/diffpy/srmise/basefunction.py +++ b/diffpy/srmise/basefunction.py @@ -3,8 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/baselines/arbitrary.py b/diffpy/srmise/baselines/arbitrary.py index 6d1fe0d..bda2494 100644 --- a/diffpy/srmise/baselines/arbitrary.py +++ b/diffpy/srmise/baselines/arbitrary.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund @@ -89,11 +89,12 @@ def __init__(self, npars, valuef, jacobianf=None, estimatef=None, Cache=None): # TODO: figure out how the metadict can be used to save the functions # and use them again when a file is loaded... - metadict = {} - metadict["npars"] = (npars, repr) - metadict["valuef"] = (valuef, repr) - metadict["jacobianf"] = (jacobianf, repr) - metadict["estimatef"] = (estimatef, repr) + metadict = { + "npars": (npars, repr), + "valuef": (valuef, repr), + "jacobianf": (jacobianf, repr), + "estimatef": (estimatef, repr), + } BaselineFunction.__init__(self, parameterdict, formats, default_formats, metadict, None, Cache) # Methods required by BaselineFunction #### @@ -182,7 +183,6 @@ def _transform_parametersraw(self, pars, in_format, out_format): def _valueraw(self, pars, r): """Return value of polynomial for the given parameters and r values. - Parameters Parameters pars: Sequence of parameters pars[0] = a_0 diff --git a/diffpy/srmise/baselines/base.py b/diffpy/srmise/baselines/base.py index 7324f8d..ca58155 100644 --- a/diffpy/srmise/baselines/base.py +++ b/diffpy/srmise/baselines/base.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/baselines/fromsequence.py b/diffpy/srmise/baselines/fromsequence.py index 120a359..4d4c553 100644 --- a/diffpy/srmise/baselines/fromsequence.py +++ b/diffpy/srmise/baselines/fromsequence.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/baselines/nanospherical.py b/diffpy/srmise/baselines/nanospherical.py index 4781312..b45113b 100644 --- a/diffpy/srmise/baselines/nanospherical.py +++ b/diffpy/srmise/baselines/nanospherical.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund @@ -35,7 +35,7 @@ class NanoSpherical(BaselineFunction): scale factor is 4*pi*rho_0, where rho_r is the nanoparticle density. gamma_0(r) Reference: - Guinier et. al. (1955). Small-angle Scattering from X-rays. New York: John Wiley & Sons, Inc. + Guinier et al. (1955). Small-angle Scattering from X-rays. New York: John Wiley & Sons, Inc. """ def __init__(self, Cache=None): diff --git a/diffpy/srmise/baselines/polynomial.py b/diffpy/srmise/baselines/polynomial.py index d7ba84a..70498be 100644 --- a/diffpy/srmise/baselines/polynomial.py +++ b/diffpy/srmise/baselines/polynomial.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund @@ -49,8 +49,7 @@ def __init__(self, degree, Cache=None): parameterdict["a_" + str(d)] = self.degree - d formats = ["internal"] default_formats = {"default_input": "internal", "default_output": "internal"} - metadict = {} - metadict["degree"] = (degree, repr) + metadict = {"degree": (degree, repr)} BaselineFunction.__init__(self, parameterdict, formats, default_formats, metadict, None, Cache) # Methods required by BaselineFunction #### @@ -95,12 +94,11 @@ def estimate_parameters(self, r, y): import numpy.linalg as la - A = np.array([r[cut_idx]]).T - slope = la.lstsq(A, y[cut_idx])[0][0] + a = np.array([r[cut_idx]]).T + slope = la.lstsq(a, y[cut_idx])[0][0] return np.array([slope, 0.0]) except Exception as e: emsg = "Error during estimation -- " + str(e) - raise raise SrMiseEstimationError(emsg) def _jacobianraw(self, pars, r, free): diff --git a/diffpy/srmise/dataclusters.py b/diffpy/srmise/dataclusters.py index 6b64333..d87a6b9 100644 --- a/diffpy/srmise/dataclusters.py +++ b/diffpy/srmise/dataclusters.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/modelcluster.py b/diffpy/srmise/modelcluster.py index d7d1742..cf952b2 100644 --- a/diffpy/srmise/modelcluster.py +++ b/diffpy/srmise/modelcluster.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/modelevaluators/aic.py b/diffpy/srmise/modelevaluators/aic.py index a8d870b..e3ee9e4 100644 --- a/diffpy/srmise/modelevaluators/aic.py +++ b/diffpy/srmise/modelevaluators/aic.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/modelevaluators/aicc.py b/diffpy/srmise/modelevaluators/aicc.py index 18e950b..be1052f 100644 --- a/diffpy/srmise/modelevaluators/aicc.py +++ b/diffpy/srmise/modelevaluators/aicc.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/modelevaluators/base.py b/diffpy/srmise/modelevaluators/base.py index b51e965..2e97b3a 100644 --- a/diffpy/srmise/modelevaluators/base.py +++ b/diffpy/srmise/modelevaluators/base.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/peaks/base.py b/diffpy/srmise/peaks/base.py index 47e7a78..653a0e3 100644 --- a/diffpy/srmise/peaks/base.py +++ b/diffpy/srmise/peaks/base.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/peaks/gaussian.py b/diffpy/srmise/peaks/gaussian.py index 2c12788..ad2530b 100644 --- a/diffpy/srmise/peaks/gaussian.py +++ b/diffpy/srmise/peaks/gaussian.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/peaks/gaussianoverr.py b/diffpy/srmise/peaks/gaussianoverr.py index d5e8656..a5f9794 100644 --- a/diffpy/srmise/peaks/gaussianoverr.py +++ b/diffpy/srmise/peaks/gaussianoverr.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund diff --git a/diffpy/srmise/peaks/terminationripples.py b/diffpy/srmise/peaks/terminationripples.py index f916d3b..e814820 100644 --- a/diffpy/srmise/peaks/terminationripples.py +++ b/diffpy/srmise/peaks/terminationripples.py @@ -3,7 +3,7 @@ # # SrMise by Luke Granlund # (c) 2014 trustees of the Michigan State University -# (c) 2024 trustees of Columia University in the City of New York +# (c) 2024 trustees of Columbia University in the City of New York # All rights reserved. # # File coded by: Luke Granlund