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

Commit a7bf740

Browse files
authored
Merge pull request #291 from ndawe/master
Support new TMVA DataLoader API
2 parents f347b8a + 9970c54 commit a7bf740

File tree

13 files changed

+18357
-10712
lines changed

13 files changed

+18357
-10712
lines changed

.coveragerc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# .coveragerc to control coverage.py
2-
# based on http://nedbatchelder.com/code/coverage/config.html
2+
# based on http://coverage.readthedocs.io/en/latest/config.html
33
[run]
44
branch = True
55
source = root_numpy
@@ -9,6 +9,7 @@ omit =
99
*/root_numpy/extern/*
1010
*/root_numpy/setup_utils.py
1111
*/setup.py
12+
*/tests.py
1213
[report]
1314
exclude_lines =
1415
# Enable the standard pragma

docs/reference/index.rst

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@ root_numpy
4545
root_numpy.tmva
4646
---------------
4747

48-
.. warning:: The interface of TMVA has changed in ROOT 6.07. So building
49-
root_numpy there will fail until we can handle their new DataLoader
50-
interface. In the meantime disable the TMVA interface with the following
51-
if you must use ROOT 6.07 with TMVA enabled::
52-
53-
NOTMVA=1 pip install --upgrade --user root_numpy
54-
55-
Note that if TMVA is not enabled in the ROOT build, root_numpy will anyway
56-
not attempt to build the TMVA interface.
57-
5848
.. currentmodule:: root_numpy.tmva
5949

6050
.. autosummary::

root_numpy/setup_utils.py

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
11
import os
2+
import re
23
import subprocess
4+
import numbers
5+
from collections import namedtuple
6+
7+
8+
class ROOTVersion(namedtuple('_ROOTVersionBase',
9+
['major', 'minor', 'micro'])):
10+
11+
def __new__(cls, *version):
12+
if len(version) == 1:
13+
version = version[0]
14+
15+
if isinstance(version, numbers.Integral):
16+
if version < 1E4:
17+
raise ValueError(
18+
"{0:d} is not a valid ROOT version integer".format(version))
19+
return super(ROOTVersion, cls).__new__(
20+
cls,
21+
int(version / 1E4),
22+
int((version / 1E2) % 100),
23+
int(version % 100))
24+
25+
if isinstance(version, tuple):
26+
return super(ROOTVersion, cls).__new__(cls, *version)
27+
28+
# parse the string version X.YY/ZZ
29+
match = re.match(
30+
r"(?P<major>[\d]+)\.(?P<minor>[\d]+)/(?P<micro>[\d]+)", version)
31+
if not match:
32+
raise ValueError(
33+
"'{0}' is not a valid ROOT version string".format(version))
34+
return super(ROOTVersion, cls).__new__(
35+
cls,
36+
int(match.group('major')),
37+
int(match.group('minor')),
38+
int(match.group('micro')))
39+
40+
41+
def __eq__(self, version):
42+
if not isinstance(version, tuple):
43+
version = ROOTVersion(version)
44+
return super(ROOTVersion, self).__eq__(version)
45+
46+
def __ne__(self, version):
47+
return not self.__eq__(version)
48+
49+
def __gt__(self, version):
50+
if not isinstance(version, tuple):
51+
version = ROOTVersion(version)
52+
return super(ROOTVersion, self).__gt__(version)
53+
54+
def __ge__(self, version):
55+
if not isinstance(version, tuple):
56+
version = ROOTVersion(version)
57+
return super(ROOTVersion, self).__ge__(version)
58+
59+
def __lt__(self, version):
60+
if not isinstance(version, tuple):
61+
version = ROOTVersion(version)
62+
return super(ROOTVersion, self).__lt__(version)
63+
64+
def __le__(self, version):
65+
if not isinstance(version, tuple):
66+
version = ROOTVersion(version)
67+
return super(ROOTVersion, self).__le__(version)
68+
69+
def __repr__(self):
70+
return str(self)
71+
72+
def __str__(self):
73+
return '{0:d}.{1:02d}/{2:02d}'.format(*self)
374

475

576
def root_flags(root_config='root-config'):
@@ -33,12 +104,12 @@ def root_version_installed(root_config='root-config'):
33104
stdout=subprocess.PIPE).communicate()[0].strip()
34105
if sys.version > '3':
35106
root_vers = root_vers.decode('utf-8')
36-
return root_vers
107+
return ROOTVersion(root_vers)
37108

38109

39110
def root_version_active():
40111
import ROOT
41-
return ROOT.gROOT.GetVersion()
112+
return ROOTVersion(ROOT.gROOT.GetVersionInt())
42113

43114

44115
def get_config():

0 commit comments

Comments
 (0)