Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Support new TMVA DataLoader API #291

Merged
merged 6 commits into from
Nov 28, 2016
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
3 changes: 2 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# .coveragerc to control coverage.py
# based on http://nedbatchelder.com/code/coverage/config.html
# based on http://coverage.readthedocs.io/en/latest/config.html
[run]
branch = True
source = root_numpy
Expand All @@ -9,6 +9,7 @@ omit =
*/root_numpy/extern/*
*/root_numpy/setup_utils.py
*/setup.py
*/tests.py
[report]
exclude_lines =
# Enable the standard pragma
Expand Down
10 changes: 0 additions & 10 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ root_numpy
root_numpy.tmva
---------------

.. warning:: The interface of TMVA has changed in ROOT 6.07. So building
root_numpy there will fail until we can handle their new DataLoader
interface. In the meantime disable the TMVA interface with the following
if you must use ROOT 6.07 with TMVA enabled::

NOTMVA=1 pip install --upgrade --user root_numpy

Note that if TMVA is not enabled in the ROOT build, root_numpy will anyway
not attempt to build the TMVA interface.

.. currentmodule:: root_numpy.tmva

.. autosummary::
Expand Down
75 changes: 73 additions & 2 deletions root_numpy/setup_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,76 @@
import os
import re
import subprocess
import numbers
from collections import namedtuple


class ROOTVersion(namedtuple('_ROOTVersionBase',
['major', 'minor', 'micro'])):

def __new__(cls, *version):
if len(version) == 1:
version = version[0]

if isinstance(version, numbers.Integral):
if version < 1E4:
raise ValueError(
"{0:d} is not a valid ROOT version integer".format(version))
return super(ROOTVersion, cls).__new__(
cls,
int(version / 1E4),
int((version / 1E2) % 100),
int(version % 100))

if isinstance(version, tuple):
return super(ROOTVersion, cls).__new__(cls, *version)

# parse the string version X.YY/ZZ
match = re.match(
r"(?P<major>[\d]+)\.(?P<minor>[\d]+)/(?P<micro>[\d]+)", version)
if not match:
raise ValueError(
"'{0}' is not a valid ROOT version string".format(version))
return super(ROOTVersion, cls).__new__(
cls,
int(match.group('major')),
int(match.group('minor')),
int(match.group('micro')))


def __eq__(self, version):
if not isinstance(version, tuple):
version = ROOTVersion(version)
return super(ROOTVersion, self).__eq__(version)

def __ne__(self, version):
return not self.__eq__(version)

def __gt__(self, version):
if not isinstance(version, tuple):
version = ROOTVersion(version)
return super(ROOTVersion, self).__gt__(version)

def __ge__(self, version):
if not isinstance(version, tuple):
version = ROOTVersion(version)
return super(ROOTVersion, self).__ge__(version)

def __lt__(self, version):
if not isinstance(version, tuple):
version = ROOTVersion(version)
return super(ROOTVersion, self).__lt__(version)

def __le__(self, version):
if not isinstance(version, tuple):
version = ROOTVersion(version)
return super(ROOTVersion, self).__le__(version)

def __repr__(self):
return str(self)

def __str__(self):
return '{0:d}.{1:02d}/{2:02d}'.format(*self)


def root_flags(root_config='root-config'):
Expand Down Expand Up @@ -33,12 +104,12 @@ def root_version_installed(root_config='root-config'):
stdout=subprocess.PIPE).communicate()[0].strip()
if sys.version > '3':
root_vers = root_vers.decode('utf-8')
return root_vers
return ROOTVersion(root_vers)


def root_version_active():
import ROOT
return ROOT.gROOT.GetVersion()
return ROOTVersion(ROOT.gROOT.GetVersionInt())


def get_config():
Expand Down
Loading