Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gPad is not consistent in pyROOT #15498

Open
1 task done
linev opened this issue May 13, 2024 · 5 comments
Open
1 task done

gPad is not consistent in pyROOT #15498

linev opened this issue May 13, 2024 · 5 comments

Comments

@linev
Copy link
Member

linev commented May 13, 2024

Check duplicate issues.

  • Checked for duplicates

Description

If configuring any web display, gPad is not properly set.
As a result, h.Draw creates new canvas.
Code works properly when gROOT.SetWebDisplay("off") invoked.

Reproducer

Here is reproducer:

import ROOT

ROOT.gROOT.SetWebDisplay("")

c = ROOT.TCanvas()

if ROOT.gPad:
   print("gPad name", ROOT.gPad.GetName(), "editable", ROOT.gPad.IsEditable())
else:
   print("gPad is not there - why?")

h = ROOT.TH1D("","",64, -4,4)
h.FillRandom("gaus")

# this is a problem - histogram do not "see" gPad and creates new canvas
h.Draw()

input("Press Enter to exit")

ROOT version

master branch

Python 3.11.9

Installation method

build from source

Operating system

OpenSUSE linux

Additional context

No response

@vepadulano
Copy link
Member

Just to confirm, this only happens when running ROOT from Python right? An equivalent C++ code would work?

@linev
Copy link
Member Author

linev commented May 13, 2024

Yes, similar C++ code works as expected:

{
   gROOT->SetWebDisplay("");

   auto c = new TCanvas();

   if (gPad)
      printf("gPad name %s editable %d\n", gPad->GetName(), gPad->IsEditable());
   else
      printf("gPad is not there - why?\n");

   auto h = new TH1D("","",64, -4,4);
   h->FillRandom("gaus");

   // this is a problem - histogram do not "see" gPad and creates new canvas
   h->Draw();
}

@linev
Copy link
Member Author

linev commented May 13, 2024

I just not understand how gPad can differ in h.Draw.
Are there any special pythonization for it?
Or is there other thread? gPad is thread-local variable.

@dpiparo
Copy link
Member

dpiparo commented May 27, 2024

@couet we need perhaps help

@linev
Copy link
Member Author

linev commented May 27, 2024

I do not think Olivier can help here.

Something wired with pythonization here.
At the moment when h.Draw() is called gPad is not consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants