MCPcopy Create free account
hub / github.com/KDE/labplot / testHistogramExponentialML

Method testHistogramExponentialML

tests/analysis/fit/FitTest.cpp:3887–3934  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3885}
3886
3887void FitTest::testHistogramExponentialML() {
3888 Spreadsheet spreadsheet(QStringLiteral("test"), false);
3889 AsciiFilter filter;
3890
3891 const QString& fileName = QFINDTESTDATA(QLatin1String("data/Exponential.dat"));
3892
3893 auto properties = filter.properties();
3894 properties.headerEnabled = false;
3895 filter.setProperties(properties);
3896 filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
3897
3898 QCOMPARE(spreadsheet.rowCount(), 100);
3899 QCOMPARE(spreadsheet.columnCount(), 1);
3900
3901 Worksheet worksheet(QStringLiteral("test"), false);
3902 auto* plot = new CartesianPlot(QStringLiteral("plot"));
3903 worksheet.addChild(plot);
3904
3905 auto* hist = new Histogram(QStringLiteral("Histogram"));
3906 plot->addChild(hist);
3907 hist->setDataColumn(spreadsheet.column(0));
3908
3909 // Do the fit
3910 plot->addHistogramFit(hist, nsl_sf_stats_exponential);
3911
3912 auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0));
3913 QVERIFY(fit != nullptr);
3914
3915 QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name()));
3916 // get results
3917 const XYFitCurve::FitResult& fitResult = fit->fitResult();
3918
3919 QCOMPARE(fitResult.available, true);
3920 QCOMPARE(fitResult.valid, true);
3921
3922 WARN(std::setprecision(15) << fitResult.paramValues.at(0));
3923 QCOMPARE(fitResult.paramValues.at(0), 41.6543778722);
3924 WARN(std::setprecision(15) << fitResult.paramValues.at(1));
3925 QCOMPARE(fitResult.paramValues.at(1), 1.93906050400681);
3926 WARN(std::setprecision(15) << fitResult.errorValues.at(1));
3927 QCOMPARE(fitResult.errorValues.at(1), 0.195884683568035);
3928 WARN(std::setprecision(15) << fitResult.paramValues.at(1) - fitResult.marginValues.at(1));
3929 QCOMPARE(fitResult.paramValues.at(1) - fitResult.marginValues.at(1), 1.5740096363284);
3930 WARN(std::setprecision(15) << fitResult.paramValues.at(1) + fitResult.margin2Values.at(1));
3931 QCOMPARE(fitResult.paramValues.at(1) + fitResult.margin2Values.at(1), 2.34119114746796);
3932 WARN(std::setprecision(15) << fitResult.paramValues.at(2));
3933 QCOMPARE(fitResult.paramValues.at(2), 5.01032231564491);
3934}
3935
3936void FitTest::testHistogramLaplaceML() {
3937 Spreadsheet spreadsheet(QStringLiteral("test"), false);

Callers

nothing calls this directly

Calls 10

setPropertiesMethod · 0.80
addHistogramFitMethod · 0.80
propertiesMethod · 0.45
readDataFromFileMethod · 0.45
rowCountMethod · 0.45
columnCountMethod · 0.45
addChildMethod · 0.45
setDataColumnMethod · 0.45
columnMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected