Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 0 additions & 82 deletions bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'include', # load and jit a header file
'c_include', # load and jit a C header file
'load_library', # load a shared library
'nullptr', # unique pointer representing NULL

Check failure on line 43 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:43:5: F405 `nullptr` may be undefined, or defined from star imports
'sizeof', # size of a C++ type
'typeid', # typeid of a C++ type
'multi', # helper for multiple inheritance
Expand All @@ -64,27 +64,27 @@
ispypy = False

from . import _typemap
from ._version import __version__

Check failure on line 67 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:67:23: F401 `._version.__version__` imported but unused; consider removing, adding to `__all__`, or using a redundant alias

# import separately instead of in the above try/except block for easier to
# understand tracebacks
if ispypy:
from ._pypy_cppyy import *

Check failure on line 72 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F403)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:72:5: F403 `from ._pypy_cppyy import *` used; unable to detect undefined names
else:
from ._cpython_cppyy import *

Check failure on line 74 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F403)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:74:5: F403 `from ._cpython_cppyy import *` used; unable to detect undefined names


#- allow importing from gbl --------------------------------------------------
sys.modules['cppyy.gbl'] = gbl

Check failure on line 78 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:78:28: F405 `gbl` may be undefined, or defined from star imports
sys.modules['cppyy.gbl.std'] = gbl.std

Check failure on line 79 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:79:32: F405 `gbl` may be undefined, or defined from star imports


#- external typemap ----------------------------------------------------------
_typemap.initialize(_backend) # also creates (u)int8_t mapper

Check failure on line 83 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:83:21: F405 `_backend` may be undefined, or defined from star imports

try:
gbl.std.int8_t = gbl.int8_t # ensures same _integer_ type

Check failure on line 86 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:86:23: F405 `gbl` may be undefined, or defined from star imports

Check failure on line 86 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:86:5: F405 `gbl` may be undefined, or defined from star imports
gbl.std.uint8_t = gbl.uint8_t

Check failure on line 87 in bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F405)

bindings/pyroot/cppyy/cppyy/python/cppyy/__init__.py:87:5: F405 `gbl` may be undefined, or defined from star imports
except (AttributeError, TypeError):
pass

Expand Down Expand Up @@ -297,88 +297,6 @@
if os.path.exists(apipath) and os.path.exists(os.path.join(apipath, 'Python.h')):
add_include_path(apipath)

# add access to extra headers for dispatcher (CPyCppyy only (?))
if not ispypy:
try:
apipath_extra = os.environ['CPPYY_API_PATH']
if os.path.basename(apipath_extra) == 'CPyCppyy':
apipath_extra = os.path.dirname(apipath_extra)
except KeyError:
apipath_extra = None

if apipath_extra is None:
try:
if 0x30a0000 <= sys.hexversion:
import importlib.metadata as m

for p in m.files('CPyCppyy'):
if p.match('API.h'):
ape = p.locate()
break
del p, m
else:
import pkg_resources as pr

d = pr.get_distribution('CPyCppyy')
for line in d.get_metadata_lines('RECORD'):
if 'API.h' in line:
ape = os.path.join(d.location, line[0:line.find(',')])
break
del line, d, pr

if os.path.exists(ape):
apipath_extra = os.path.dirname(os.path.dirname(ape))
del ape
except Exception:
pass

if apipath_extra is None:
ldversion = sysconfig.get_config_var('LDVERSION')
if not ldversion:
ldversion = sys.version[:3]

apipath_extra = os.path.join(os.path.dirname(apipath), 'site', 'python'+ldversion)
if not os.path.exists(os.path.join(apipath_extra, 'CPyCppyy')):
import glob
import platform

if platform.system() == "Windows":
# Install locations are handled differently on Windows
import libcppyy

ape = os.path.dirname(libcppyy.__file__)
else:
import cppyy.libcppyy as libcppyy

ape = os.path.dirname(libcppyy.__file__)
# a "normal" structure finds the include directory up to 3 levels up,
# ie. dropping lib/pythonx.y[md]/site-packages
for i in range(3):
if os.path.exists(os.path.join(ape, 'include')):
break
ape = os.path.dirname(ape)

ape = os.path.join(ape, 'include')
if os.path.exists(os.path.join(ape, 'CPyCppyy')):
apipath_extra = ape
else:
# add back pythonx.y or site/pythonx.y if present
for p in glob.glob(os.path.join(ape, 'python'+sys.version[:3]+'*'))+\
glob.glob(os.path.join(ape, '*', 'python'+sys.version[:3]+'*')):
if os.path.exists(os.path.join(p, 'CPyCppyy')):
apipath_extra = p
break

if apipath_extra.lower() != 'none':
if not os.path.exists(os.path.join(apipath_extra, 'CPyCppyy')):
warnings.warn("CPyCppyy API not found (tried: %s); "
"set CPPYY_API_PATH envar to the 'CPyCppyy' API directory to fix"
% apipath_extra)
else:
add_include_path(apipath_extra)

del apipath_extra

if os.getenv('CONDA_PREFIX'):
# MacOS, Linux
include_path = os.path.join(os.getenv('CONDA_PREFIX'), 'include')
Expand Down
9 changes: 8 additions & 1 deletion bindings/pyroot/pythonizations/test/numbadeclare.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ class NumbaDeclareSimple(unittest.TestCase):
def test_refcount_decorator(self):
"""
Test refcount of decorator

In case of Python < 3.14, we expect a refcount of 2, because the call
to sys.getrefcount can create an additional reference itself. Starting
from Python 3.14, we expect a refcount of 1 because there were changes
to the interpreter to avoid some unnecessary ref counts. See also:
https://docs.python.org/3.14/whatsnew/3.14.html#whatsnew314-refcount
"""
x = ROOT.Numba.Declare(["float"], "float")
gc.collect()
self.assertEqual(sys.getrefcount(x), 2)
extra_ref_count = int(sys.version_info < (3, 14))
self.assertEqual(sys.getrefcount(x), 1 + extra_ref_count)

def test_refcount_pycallable(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_refcount(self):
"""
Check refcounts of associated PyObjects

In case of Python <=3.14, we expect a refcount of 2 for the data dict,
In case of Python < 3.14, we expect a refcount of 2 for the data dict,
because the call to sys.getrefcount creates a second reference by
itself. Starting from Python 3.14, we expect a refcount of 1 because
there were changes to the interpreter to avoid some unnecessary ref
Expand Down
2 changes: 1 addition & 1 deletion bindings/pyroot/pythonizations/test/rvec_asrvec.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_refcount(self):
"""
Test reference count of returned RVec

In case of Python <=3.14, we expect a refcount of 2 for the RVec
In case of Python < 3.14, we expect a refcount of 2 for the RVec
because the call to sys.getrefcount creates a second reference by
itself. Starting from Python 3.14, we expect a refcount of 1 because
there were changes to the interpreter to avoid some unnecessary ref
Expand Down
9 changes: 5 additions & 4 deletions roofit/roofit/src/RooLognormal.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ The parameterization here is physics driven and differs from the ROOT::Math::log

#include "RooLognormal.h"
#include "RooRandom.h"
#include "RooMath.h"
#include "RooHelpers.h"
#include "RooBatchCompute.h"

Expand Down Expand Up @@ -104,9 +103,11 @@ double RooLognormal::analyticalIntegral(Int_t /*code*/, const char *rangeName) c
static const double root2 = std::sqrt(2.);

double ln_k = std::abs(_useStandardParametrization ? k : std::log(k));
double scaledMin = _useStandardParametrization ? std::log(x.min(rangeName)) - m0 : std::log(x.min(rangeName) / m0);
double scaledMax = _useStandardParametrization ? std::log(x.max(rangeName)) - m0 : std::log(x.max(rangeName) / m0);
return 0.5 * (RooMath::erf(scaledMax / (root2 * ln_k)) - RooMath::erf(scaledMin / (root2 * ln_k)));
const double xMin = std::max(x.min(rangeName), 0.);
const double xMax = x.max(rangeName);
double scaledMax = _useStandardParametrization ? std::log(xMax) - m0 : std::log(xMax / m0);
double scaledMin = _useStandardParametrization ? std::log(xMin) - m0 : std::log(xMin / m0);
return 0.5 * (std::erf(scaledMax / (root2 * ln_k)) - std::erf(scaledMin / (root2 * ln_k)));
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion roottest/python/basic/PyROOT_datatypetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ def test09_global_builtin_types(self):
setattr(gbl, 'g_'+name, adat)
assert getattr(gbl, 'g_'+name) == adat
assert getattr(gbl, 'g_c_'+name) == cdat
raises(TypeError, setattr, 'g_c_'+name, acdat)
raises(TypeError, setattr, gbl, 'g_c_'+name, acdat)
testcount += 1
assert testcount == len(testdata)

Expand Down
7 changes: 5 additions & 2 deletions tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ if(NOT xrootd)
roofit/roofit/rf618_mixture_models.py # depends on df106_HiggsToFourLeptons.py
visualisation/rcanvas/df104.py
visualisation/rcanvas/df105.py
io/tree/imt_parTreeProcessing.C
)
endif()

Expand Down Expand Up @@ -284,8 +285,6 @@ endif()
if(MSVC)
#---Multiproc is not supported on Windows
set(imt_veto ${imt_veto} analysis/parallel/mp*.C io/tree/mp*.C legacy/multicore/mp*.C multicore/mp*.C ./analysis/parallel/mtbb_parallelHistoFill.C)
#---XRootD is not supported on Windows
set(imt_veto ${imt_veto} io/tree/imt_parTreeProcessing.C)
endif()

if(ROOT_CLASSIC_BUILD)
Expand Down Expand Up @@ -864,6 +863,7 @@ if(ROOT_pyroot_FOUND)
tutorial-legacy-g3d-na49view-py
tutorial-hist-hist015_TH1_read_and_draw-py
tutorial-io-tree-ntuple1-py)
set(hist-hist015_TH1_read_and_draw_uhi-depends tutorial-hsimple-py)
set(math-fit-fit1-depends tutorial-hist-hist001_TH1_fillrandom-py)
set(legacy-g3d-na49view-depends tutorial-legacy-g3d-geometry-py)
set(roofit-roofit-rf503_wspaceread-depends tutorial-roofit-roofit-rf502_wspacewrite-py)
Expand All @@ -882,6 +882,9 @@ if(ROOT_pyroot_FOUND)
# To add a new requirement, add a glob expression that's named requires_<packageName>,
# and add it to the list "fixtureLists" below.
file(GLOB requires_numpy RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
hsimple.py
io/tree/ntuple1.py # indirect dependency from hsimple.py
hist/hist015_TH1_read_and_draw.py # indirect dependency from hsimple.py
analysis/dataframe/df017_vecOpsHEP.py
analysis/dataframe/df026_AsNumpyArrays.py
analysis/dataframe/df032_RDFFromNumpy.py
Expand Down
10 changes: 3 additions & 7 deletions tutorials/hist/hist015_TH1_read_and_draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,10 @@
pad2.Draw()
pad3.Draw()
#
# We connect the ROOT file generated in a previous tutorial
# We connect the ROOT file generated in the hsimple.py tutorial
#
File = "py-hsimple.root"
if (ROOT.gSystem.AccessPathName(File)) :
ROOT.Info("hist015_TH1_read_and_draw.py", File+" does not exist")
exit()

example = TFile(File)
example = TFile("py-hsimple.root")
example.ls()

# Draw a global picture title
Expand Down Expand Up @@ -86,4 +82,4 @@
c1.Update()

if (example.IsOpen()):
example.Close()
example.Close()
8 changes: 2 additions & 6 deletions tutorials/hist/hist015_TH1_read_and_draw_uhi.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,9 @@
mpl_fig = plt.figure(figsize=(14, 12))
gs = mpl_fig.add_gridspec(3, 2, height_ratios=[1.5, 1.5, 1.5])

# We connect the ROOT file generated in a previous tutorial
File = "py-hsimple.root"
if ROOT.gSystem.AccessPathName(File):
ROOT.Info("hist015_TH1_read_and_draw.py", File + " does not exist")
exit()
# We connect the ROOT file generated in the hsimple.py tutorial

example = TFile(File)
example = TFile("py-hsimple.root")
example.ls()

# Draw histogram hpx in first pad.
Expand Down
Loading