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

Method testHistogramLaplaceML

tests/analysis/fit/FitTest.cpp:3936–3977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3934}
3935
3936void FitTest::testHistogramLaplaceML() {
3937 Spreadsheet spreadsheet(QStringLiteral("test"), false);
3938 AsciiFilter filter;
3939
3940 const QString& fileName = QFINDTESTDATA(QLatin1String("data/Laplace.dat"));
3941
3942 auto properties = filter.properties();
3943 properties.headerEnabled = false;
3944 filter.setProperties(properties);
3945 filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
3946
3947 QCOMPARE(spreadsheet.rowCount(), 100);
3948 QCOMPARE(spreadsheet.columnCount(), 1);
3949
3950 Worksheet worksheet(QStringLiteral("test"), false);
3951 auto* plot = new CartesianPlot(QStringLiteral("plot"));
3952 worksheet.addChild(plot);
3953
3954 auto* hist = new Histogram(QStringLiteral("Histogram"));
3955 plot->addChild(hist);
3956 hist->setDataColumn(spreadsheet.column(0));
3957
3958 // Do the fit
3959 plot->addHistogramFit(hist, nsl_sf_stats_laplace);
3960
3961 auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0));
3962 QVERIFY(fit != nullptr);
3963
3964 QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name()));
3965 // get results
3966 const XYFitCurve::FitResult& fitResult = fit->fitResult();
3967
3968 QCOMPARE(fitResult.available, true);
3969 QCOMPARE(fitResult.valid, true);
3970
3971 WARN(std::setprecision(15) << fitResult.paramValues.at(0));
3972 QCOMPARE(fitResult.paramValues.at(0), 145.64147805241);
3973 WARN(std::setprecision(15) << fitResult.paramValues.at(1));
3974 QCOMPARE(fitResult.paramValues.at(1), 1.99538835213796);
3975 WARN(std::setprecision(15) << fitResult.paramValues.at(2));
3976 QCOMPARE(fitResult.paramValues.at(2), 4.95890340967321);
3977}
3978
3979void FitTest::testHistogramCauchyML() {
3980 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