Skip to content

pyROOT TH1::GetDefaultSumw2 throws error when called #20463

@jemarq04

Description

@jemarq04

Check duplicate issues.

  • Checked for duplicates

Description

When calling class method TH1::GetDefaultSumw2(), python3 throws the following error:

TypeError: static bool TH1::GetDefaultSumw2() =>
    TypeError: takes at most 0 arguments (1 given)

The method takes 0 arguments in the documentation. I assume the "1 given" here is the instance itself passed to the method of the class, but this doesn't happen with other methods of TH1 that I have noticed.

Reproducer

Fails when running in Python 3.9.14 (should be similar in any Python 3).

import ROOT
hist = ROOT.TH1F("h", "histogram", 100, -3, 3)
print(hist.GetDefaultSumw2()) #throws error here

Works find in C++ (ran with root temp.cc)

//in temp.cc
#include <iostream>                                                                      
#include "TH1.h"                                                                         
                                                                                         
void temp(){                                                                             
  auto *hist = new TH1F("h", "histogram", 100, -3, 3);                                   
  std::cout << hist->GetDefaultSumw2() << std::endl;                                     
}

ROOT version

ROOT Version: 6.36.04
Built for macosx64 on Aug 25 2025, 09:02:18
From tags/6-36-04@6-36-04

Installation method

homebrew package manager

Operating system

MacOS 15.5

Additional context

Bug also found in older version (6.32.13) found in new CMSSW virtual environments (e.g. CMSSW_15_0_14)

Metadata

Metadata

Assignees

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions