Skip to content

Commit 087250f

Browse files
committed
[df] Extend axis of weighted Histo1D
Fixes #19362
1 parent bdfd632 commit 087250f

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tree/dataframe/inc/ROOT/RDF/RInterface.hxx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,9 @@ public:
20012001
ROOT::Internal::RDF::RIgnoreErrorLevelRAII iel(kError);
20022002
h = model.GetHistogram();
20032003
}
2004+
2005+
if (h->GetXaxis()->GetXmax() == h->GetXaxis()->GetXmin())
2006+
h->SetCanExtend(::TH1::kAllAxes);
20042007
return CreateAction<RDFInternal::ActionTags::Histo1D, V, W>(userColumns, h, h, fProxiedPtr);
20052008
}
20062009

tree/dataframe/test/dataframe_simple.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,15 @@ TEST_P(RDFSimpleTests, TakeCarrays)
519519
gSystem->Unlink(fileName);
520520
}
521521

522+
TEST_P(RDFSimpleTests, HistoExtend)
523+
{
524+
auto d = RDataFrame(10000).Define("x", "rdfentry_");
525+
auto hist = d.Histo1D("x");
526+
EXPECT_GE(hist->GetXaxis()->GetXmax(), 10000);
527+
auto histWeighted = d.Define("w", "1").Histo1D("x", "w");
528+
EXPECT_GE(histWeighted->GetXaxis()->GetXmax(), 10000);
529+
}
530+
522531
TEST_P(RDFSimpleTests, Reduce)
523532
{
524533
auto d = RDataFrame(5).DefineSlotEntry("x", [](unsigned int, ULong64_t e) { return static_cast<int>(e) + 1; });

0 commit comments

Comments
 (0)