Skip to content

Commit

Permalink
[RF] Disable tests using legacy backend if it's not available
Browse files Browse the repository at this point in the history
This can be easily done with private RooFit macros, which was the
original motivation for moving these tests inside the main repo.
  • Loading branch information
guitargeek committed Oct 26, 2024
1 parent 9ea0764 commit 226e4c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
37 changes: 21 additions & 16 deletions roofit/roofit/test/vectorisedPDFs/VectorisedPDFTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,6 @@ class PDFTestWeightedData : public PDFTest {
std::cout << "\nMaximal relative error (scalar vs batch) is: " << maximalRelativeError << "\n\n"; \
}

/// Run a fit for batch and scalar code and compare results.
#define FIT_TEST_BATCH_VS_SCALAR(TEST_CLASS, TEST_NAME) \
TEST_F(TEST_CLASS, TEST_NAME) \
{ \
runBatchVsScalar(); \
}

/// Run a fit for batch and scalar code and compare results.
/// Clone the PDFs before running the tests. This can run the test even if some internal state
/// is propagated / saved wrongly.
#define FIT_TEST_BATCH_VS_SCALAR_CLONE_PDF(TEST_CLASS, TEST_NAME) \
TEST_F(TEST_CLASS, TEST_NAME) \
{ \
runBatchVsScalar(true); \
}

/// Run a fit in batch mode and compare results to pre-fit values.
#define FIT_TEST_BATCH(TEST_CLASS, TEST_NAME) \
TEST_F(TEST_CLASS, TEST_NAME) \
Expand All @@ -181,6 +165,18 @@ class PDFTestWeightedData : public PDFTest {
checkParameters(); \
}

#ifdef ROOFIT_LEGACY_EVAL_BACKEND

/// Run a fit for batch and scalar code and compare results.
#define FIT_TEST_BATCH_VS_SCALAR(TEST_CLASS, TEST_NAME) \
TEST_F(TEST_CLASS, TEST_NAME) { runBatchVsScalar(); }

/// Run a fit for batch and scalar code and compare results.
/// Clone the PDFs before running the tests. This can run the test even if some internal state
/// is propagated / saved wrongly.
#define FIT_TEST_BATCH_VS_SCALAR_CLONE_PDF(TEST_CLASS, TEST_NAME) \
TEST_F(TEST_CLASS, TEST_NAME) { runBatchVsScalar(true); }

/// Run a fit in legacy mode and compare results to pre-fit values.
#define FIT_TEST_SCALAR(TEST_CLASS, TEST_NAME) \
TEST_F(TEST_CLASS, TEST_NAME) \
Expand All @@ -189,3 +185,12 @@ class PDFTestWeightedData : public PDFTest {
ASSERT_NE(result, nullptr); \
checkParameters(); \
}

#else

// Ignore legacy tests if legacy backend is not available
#define FIT_TEST_BATCH_VS_SCALAR(TEST_CLASS, TEST_NAME)
#define FIT_TEST_BATCH_VS_SCALAR_CLONE_PDF(TEST_CLASS, TEST_NAME)
#define FIT_TEST_SCALAR(TEST_CLASS, TEST_NAME)

#endif
4 changes: 4 additions & 0 deletions roofit/roofit/test/vectorisedPDFs/testGaussBinned.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ TEST_P(GaussBinnedFit, DISABLED_BatchFitFineBins)
EXPECT_NEAR(s.getVal(), 4., s.getError());
}

#ifdef ROOFIT_LEGACY_EVAL_BACKEND
INSTANTIATE_TEST_SUITE_P(RunFits, GaussBinnedFit,
testing::Values(RooFit::EvalBackend::Value::Legacy, RooFit::EvalBackend::Value::Cpu));
#else
INSTANTIATE_TEST_SUITE_P(RunFits, GaussBinnedFit, testing::Values(RooFit::EvalBackend::Value::Cpu));
#endif

// TODO Test a batch fit that uses categories once categories can be passed through the batch interface.

0 comments on commit 226e4c0

Please sign in to comment.