Flush onpartial cout/cerr in jupyter notebook

I have implemented a simple callback for OnPartialResult for RDataFrame. Everything inside a jupyter notebook

ROOT.gInterpreter.Declare(
    r"""
    void my_callback_(TH1D &h) { std::cerr << (int)h.GetEntries() << std::endl; }
    std::function<void(TH1D &)> my_callback = my_callback_;
    """
)

# ...

df = df.Define("zero", "0.")
histo_counting_all = df.Histo1D(("histo_counting_all", "n entries", 1, 0.0, 1.0), "zero")
histo_counting_all.OnPartialResult(10000, ROOT.my_callback)

It works, but the output is printed at the end, not during the processing. Is there a way to force the output to be flushed on the cell output?


ROOT Version: 6.26/10
Platform: Not Provided
Compiler: Not Provided


Try: std::cerr << (int)h.GetEntries() << std::endl << std::flush;

Mmmh I see how this is annoying but I think it comes down to the jupyter kernel implementation.

Maybe @etejedor knows more, if he still gets these pings? :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.