root
root copied to clipboard
[hist] Using TKDE::Fill works with empty tkde
This PR fixes
- https://github.com/root-project/root/issues/7808
This is happening because in when the parentheses operator overload TKDE::operator()(Double_t x)
calls ReInit (const_cast<TKDE*>(this))->ReInit()
it returns before setting the fKernel in the case of new data.
One approach is to call SetKernel here:
if (fNewData) {
InitFromNewData();
SetKernel();
return;
}
or call it at the end of InitFromNewData().
When that happens, the fKernel is no longer null but this error is reproducible with both iterative options - With Adaptive we get NaN and Fixed we get inf
This is because the weight calculation is using the nSum that is 0 when binning is not used Inversing that gives the infinity in the Iteration:Fixed case
This fix:
- adds the call to SetBinCountData() in InitFromNewData()
- recreates the kernel fun pointer (previously fKernel ends up a
nullptr
) - calculating nSum as fNEvents if not binning in TKDE::TKernel::operator().
Results:
auto kde = new TKDE(0, nullptr, 0, 5, "KernelType:Gaussian;Iteration:Adaptive;Mirror:noMirror;Binning:RelaxedBinning", 1);
for (unsigned int i = 0; i < 100; i++) { kde->Fill(gRandom->Gaus(2,1)); }
std::cout<<kde->GetValue(2)<<"\n";
Gives 0.487581
Can one of the admins verify this patch?
@phsft-bot build
Starting build on ROOT-performance-centos8-multicore
/soversion
, ROOT-ubuntu2204
/nortcxxmod
, ROOT-ubuntu2004
/python3
, mac12arm
/cxx20
, windows10
/default
How to customize builds
Build failed on ROOT-ubuntu2004/python3. See console output.
Build failed on ROOT-ubuntu2204/nortcxxmod. Running on root-ubuntu-2204-2.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on windows10/default. Running on null:C:\build\workspace\root-pullrequests-build See console output.
Failing tests:
Build failed on ROOT-performance-centos8-multicore/soversion. Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build See console output.
Failing tests:
Build failed on mac12arm/cxx20. Running on 194.12.161.128:/Users/sftnight/build/workspace/root-pullrequests-build See console output.
Failing tests:
Test Results
12 files 12 suites 2d 5h 22m 15s :stopwatch: 2 561 tests 2 559 :white_check_mark: 0 :zzz: 2 :x: 28 810 runs 28 796 :white_check_mark: 0 :zzz: 14 :x:
For more details on these failures, see this check.
Results for commit e8707bd9.