コード例 #1
0
    def __init__(self, *args, **kwargs):

        # set the data set object
        if args and isinstance(args[0], dts.XYDataSet):
            self.dataset = args[0]
            fmt = kwargs.pop("fmt", args[1] if len(args) >= 2 else "")
        else:
            self.dataset = dts.XYDataSet(*args, **kwargs)
            fmt = kwargs.pop("fmt", "")

        label = kwargs.pop("label", self.dataset.name)
        fmt = fmt if fmt else "o"

        # call super constructors
        XYObjectOnPlot.__init__(self, label=label, fmt=fmt, **kwargs)
コード例 #2
0
ファイル: fitting.py プロジェクト: edewit92/qexpy
def __try_fit_to_xdata_and_ydata(*args, **kwargs):
    """Helper function to parse the inputs to a call to fit() for separate xdata and ydata"""

    xdata = kwargs.pop("xdata", args[0] if args else None)
    ydata = kwargs.pop("ydata", args[1] if len(args) > 1 else None)
    model = kwargs.pop("model", args[2] if len(args) > 2 else None)

    if not isinstance(xdata, dts.ExperimentalValueArray):
        xdata = np.asarray(xdata) if isinstance(xdata,
                                                ARRAY_TYPES) else np.empty(0)

    if not isinstance(ydata, dts.ExperimentalValueArray):
        ydata = np.asarray(ydata) if isinstance(ydata,
                                                ARRAY_TYPES) else np.empty(0)

    if xdata.size and ydata.size and model:
        return fit_to_xy_dataset(dts.XYDataSet(xdata, ydata, **kwargs), model,
                                 **kwargs)

    return None
コード例 #3
0
 def fit_target_dataset(self) -> dts.XYDataSet:
     bins = self.bin_edges
     xvalues = [(bins[i] + bins[i + 1]) / 2 for i in range(len(bins) - 1)]
     return dts.XYDataSet(xvalues, self.n, name="histogram")