-
Notifications
You must be signed in to change notification settings - Fork 68
/
TParameter.py
85 lines (63 loc) · 1.85 KB
/
TParameter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot5/blob/main/LICENSE
"""
This module defines the behavior of ``TParameter<T>``.
"""
from __future__ import annotations
class TParameter_3c_boolean_3e_:
"""
Behaviors for ``TParameter<boolean>``.
"""
@property
def value(self):
return bool(self.member("fVal"))
def __bool__(self):
return bool(self.member("fVal"))
def __int__(self):
return int(self.member("fVal"))
def __float__(self):
return float(self.member("fVal"))
class TParameter_3c_integer_3e_:
"""
Behaviors for ``TParameter<integer>``.
"""
@property
def value(self):
return int(self.member("fVal"))
def __bool__(self):
return bool(self.member("fVal"))
def __int__(self):
return int(self.member("fVal"))
def __index__(self):
return int(self.member("fVal"))
def __float__(self):
return float(self.member("fVal"))
class TParameter_3c_floating_3e_:
"""
Behaviors for ``TParameter<floating>``.
"""
@property
def value(self):
return float(self.member("fVal"))
def __bool__(self):
return bool(self.member("fVal"))
def __int__(self):
return int(self.member("fVal"))
def __float__(self):
return float(self.member("fVal"))
def TParameter(specialization):
"""
Returns a Parameter class object for a given ``specialization``.
"""
if specialization in ("_3c_bool_3e_", "_3c_Bool_5f_t_3e_"):
return TParameter_3c_boolean_3e_
elif specialization in (
"_3c_float_3e_",
"_3c_double_3e_",
"_3c_long_20_double_3e_",
"_3c_Float_5f_t_3e_",
"_3c_Double_5f_t_3e_",
"_3c_LongDouble_5f_t_3e_",
):
return TParameter_3c_floating_3e_
else:
return TParameter_3c_integer_3e_