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

Method testHistogramCauchyML

tests/analysis/fit/FitTest.cpp:3979–4020  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3977}
3978
3979void FitTest::testHistogramCauchyML() {
3980 Spreadsheet spreadsheet(QStringLiteral("test"), false);
3981 AsciiFilter filter;
3982
3983 const QString& fileName = QFINDTESTDATA(QLatin1String("data/Cauchy.dat"));
3984
3985 auto properties = filter.properties();
3986 properties.headerEnabled = false;
3987 filter.setProperties(properties);
3988 filter.readDataFromFile(fileName, &spreadsheet, AbstractFileFilter::ImportMode::Replace);
3989
3990 QCOMPARE(spreadsheet.rowCount(), 1000);
3991 QCOMPARE(spreadsheet.columnCount(), 1);
3992
3993 Worksheet worksheet(QStringLiteral("test"), false);
3994 auto* plot = new CartesianPlot(QStringLiteral("plot"));
3995 worksheet.addChild(plot);
3996
3997 auto* hist = new Histogram(QStringLiteral("Histogram"));
3998 plot->addChild(hist);
3999 hist->setDataColumn(spreadsheet.column(0));
4000
4001 // Do the fit
4002 plot->addHistogramFit(hist, nsl_sf_stats_cauchy_lorentz);
4003
4004 auto fit = dynamic_cast<XYFitCurve*>(plot->child<XYFitCurve>(0));
4005 QVERIFY(fit != nullptr);
4006
4007 QCOMPARE(fit->name(), i18n("Distribution Fit to '%1'", hist->name()));
4008 // get results
4009 const XYFitCurve::FitResult& fitResult = fit->fitResult();
4010
4011 QCOMPARE(fitResult.available, true);
4012 QCOMPARE(fitResult.valid, true);
4013
4014 WARN(std::setprecision(15) << fitResult.paramValues.at(0));
4015 QCOMPARE(fitResult.paramValues.at(0), 34973.659700564);
4016 WARN(std::setprecision(15) << fitResult.paramValues.at(1));
4017 QCOMPARE(fitResult.paramValues.at(1), 1.87876026823743);
4018 WARN(std::setprecision(15) << fitResult.paramValues.at(2));
4019 QCOMPARE(fitResult.paramValues.at(2), 5.09155507540282);
4020}
4021
4022void FitTest::testHistogramLognormalML() {
4023 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