| 3977 | } |
| 3978 | |
| 3979 | void 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 | |
| 4022 | void FitTest::testHistogramLognormalML() { |
| 4023 | Spreadsheet spreadsheet(QStringLiteral("test"), false); |
nothing calls this directly
no test coverage detected