Skip to content

Commit ec00e79

Browse files
authored
Merge pull request #171 from MadAnalysis/observable_bugfix
Minor bugfix in `ObservableBase`
2 parents 202af1f + 247d0b6 commit ec00e79

6 files changed

Lines changed: 1470 additions & 1117 deletions

File tree

bin/ma5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ sys.path.insert(0, servicedir)
6868

6969
# Release version
7070
# Do not touch it !!!!!
71-
version = "1.10.7"
72-
date = "2023/01/06"
71+
version = "1.10.8"
72+
date = "2023/02/02"
7373

7474
# Loading the MadAnalysis session
7575
import madanalysis.core.launcher

doc/releases/changelog-v1.10.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
* Fixed attribute setting issue presented in issue [#153](https://github.com/MadAnalysis/madanalysis5/issues/153)
117117
([#154](https://github.com/MadAnalysis/madanalysis5/pull/154)).
118118

119+
* Fixed an attribute misspelling in `ObservableBase`.
120+
([#171](https://github.com/MadAnalysis/madanalysis5/pull/171))
121+
119122
## Contributors
120123

121124
This release contains contributions from (in alphabetical order):

madanalysis/observable/observable_base.py

Lines changed: 116 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,152 @@
11
################################################################################
2-
#
2+
#
33
# Copyright (C) 2012-2022 Jack Araz, Eric Conte & Benjamin Fuks
44
# The MadAnalysis development team, email: <ma5team@iphc.cnrs.fr>
5-
#
5+
#
66
# This file is part of MadAnalysis 5.
77
# Official website: <https://github.com/MadAnalysis/madanalysis5>
8-
#
8+
#
99
# MadAnalysis 5 is free software: you can redistribute it and/or modify
1010
# it under the terms of the GNU General Public License as published by
1111
# the Free Software Foundation, either version 3 of the License, or
1212
# (at your option) any later version.
13-
#
13+
#
1414
# MadAnalysis 5 is distributed in the hope that it will be useful,
1515
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1616
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1717
# GNU General Public License for more details.
18-
#
18+
#
1919
# You should have received a copy of the GNU General Public License
2020
# along with MadAnalysis 5. If not, see <http://www.gnu.org/licenses/>
21-
#
21+
#
2222
################################################################################
2323

2424

2525
from __future__ import absolute_import
2626
from madanalysis.enumeration.ma5_running_type import MA5RunningType
27-
class ObservableBase():
28-
def __init__(self,
29-
name, args, combination,
30-
plot_auto, plot_nbins, plot_xmin,
31-
plot_xmax, plot_unitX_tlatex, plot_unitX_latex,\
32-
code_parton, code_hadron, code_reco, cut_event, \
33-
cut_candidate, tlatex, latex):
34-
self.name = name
35-
self.args = args
36-
self.plot_auto = plot_auto
37-
self.plot_nbins = plot_nbins
38-
self.plot_xmin = plot_xmin
39-
self.plot_xmax = plot_xmax
40-
self.plot_unitX_tlatex = plot_unitX_tlatex
41-
self.plot_unitX_latex = plot_unitX_latex
42-
self.code_parton = code_parton
43-
self.code_hadron = code_hadron
44-
self.code_reco = code_reco
45-
self.cut_event = cut_event
46-
self.cut_candidate = cut_candidate
47-
self.combination = combination
48-
self.tlatex = tlatex
49-
self.latex = latex
5027

5128

52-
def code(self,level):
53-
if level==MA5RunningType.PARTON:
29+
class ObservableBase:
30+
def __init__(
31+
self,
32+
name,
33+
args,
34+
combination,
35+
plot_auto,
36+
plot_nbins,
37+
plot_xmin,
38+
plot_xmax,
39+
plot_unitX_tlatex,
40+
plot_unitX_latex,
41+
code_parton,
42+
code_hadron,
43+
code_reco,
44+
cut_event,
45+
cut_candidate,
46+
tlatex,
47+
latex,
48+
):
49+
self.name = name
50+
self.args = args
51+
self.plot_auto = plot_auto
52+
self.plot_nbins = plot_nbins
53+
self.plot_xmin = plot_xmin
54+
self.plot_xmax = plot_xmax
55+
self.plot_unitX_tlatex = plot_unitX_tlatex
56+
self.plot_unitX_latex = plot_unitX_latex
57+
self.code_parton = code_parton
58+
self.code_hadron = code_hadron
59+
self.code_reco = code_reco
60+
self.cut_event = cut_event
61+
self.cut_candidate = cut_candidate
62+
self.combination = combination
63+
self.tlatex = tlatex
64+
self.latex = latex
65+
66+
def code(self, level):
67+
if level == MA5RunningType.PARTON:
5468
return self.code_parton
55-
elif level==MA5RunningType.HADRON:
69+
elif level == MA5RunningType.HADRON:
5670
return self.code_hadron
57-
elif level==MA5RunningType.RECO:
71+
elif level == MA5RunningType.RECO:
5872
return self.code_reco
5973
else:
6074
return None
61-
6275

6376
@staticmethod
64-
def Clone(obs,
65-
name=None, args=None, combination=None,
66-
plot_auto=None, plot_nbins=None, plot_xmin=None,
67-
plot_xmax=None, plot_unitX_tlatex=None, plot_unitX_latex=None, code_parton=None,
68-
code_hadron=None, code_reco=None, cut_event=None, \
69-
cut_candidate=None, tlatex=None, latex=None):
77+
def Clone(
78+
obs,
79+
name=None,
80+
args=None,
81+
combination=None,
82+
plot_auto=None,
83+
plot_nbins=None,
84+
plot_xmin=None,
85+
plot_xmax=None,
86+
plot_unitX_tlatex=None,
87+
plot_unitX_latex=None,
88+
code_parton=None,
89+
code_hadron=None,
90+
code_reco=None,
91+
cut_event=None,
92+
cut_candidate=None,
93+
tlatex=None,
94+
latex=None,
95+
):
7096

7197
# create clone of obs
72-
newobs = ObservableBase(obs.name, obs.args, obs.combination,
73-
obs.plot_auto, obs.plot_nbins, obs.plot_xmin,
74-
obs.plot_xmax, obs.plot_unitX_tlatex, obs.plot_unitX_latex, obs.code_parton,
75-
obs.code_hadron, obs.code_reco, obs.cut_event,\
76-
obs.cut_candidate, obs.tlatex, obs.latex)
98+
newobs = ObservableBase(
99+
obs.name,
100+
obs.args,
101+
obs.combination,
102+
obs.plot_auto,
103+
obs.plot_nbins,
104+
obs.plot_xmin,
105+
obs.plot_xmax,
106+
obs.plot_unitX_tlatex,
107+
obs.plot_unitX_latex,
108+
obs.code_parton,
109+
obs.code_hadron,
110+
obs.code_reco,
111+
obs.cut_event,
112+
obs.cut_candidate,
113+
obs.tlatex,
114+
obs.latex,
115+
)
77116

78117
# replace
79-
if name!=None:
80-
newobs.name=name
81-
if args!=None:
82-
newobs.args=args
83-
if combination!=None:
84-
newobs.combination=combination
85-
if plot_auto!=None:
86-
newobs.plot_auto=plot_auto
87-
if plot_nbins!=None:
88-
newobs.plot_nbins=plot_nbins
89-
if plot_xmin!=None:
90-
newobs.plot_xmin=plot_xmin
91-
if plot_xmax!=None:
92-
newobs.plot_xmax=plot_xmax
93-
if plot_unitX_tlatex!=None:
94-
newobs.plot_unitX_tlatex=plot_unitX_tlatex
95-
if plot_unitX_latex!=None:
96-
newobs.plot_unitX_tlatex=plot_unitX_latex
97-
if code_parton!=None:
98-
newobs.code_parton=codeparton
99-
if code_hadron!=None:
100-
newobs.code_hadron=code_hadron
101-
if code_reco!=None:
102-
newobs.code_reco=code_reco
103-
if cut_event!=None:
104-
newobs.cut_event=cut_event
105-
if cut_candidate!=None:
106-
newobs.cut_candidate=cut_candidate
107-
if tlatex!=None:
108-
newobs.tlatex=tlatex
109-
if latex!=None:
110-
newobs.latex=latex
118+
if name is not None:
119+
newobs.name = name
120+
if args is not None:
121+
newobs.args = args
122+
if combination is not None:
123+
newobs.combination = combination
124+
if plot_auto is not None:
125+
newobs.plot_auto = plot_auto
126+
if plot_nbins is not None:
127+
newobs.plot_nbins = plot_nbins
128+
if plot_xmin is not None:
129+
newobs.plot_xmin = plot_xmin
130+
if plot_xmax is not None:
131+
newobs.plot_xmax = plot_xmax
132+
if plot_unitX_tlatex is not None:
133+
newobs.plot_unitX_tlatex = plot_unitX_tlatex
134+
if plot_unitX_latex is not None:
135+
newobs.plot_unitX_tlatex = plot_unitX_latex
136+
if code_parton is not None:
137+
newobs.code_parton = code_parton
138+
if code_hadron is not None:
139+
newobs.code_hadron = code_hadron
140+
if code_reco is not None:
141+
newobs.code_reco = code_reco
142+
if cut_event is not None:
143+
newobs.cut_event = cut_event
144+
if cut_candidate is not None:
145+
newobs.cut_candidate = cut_candidate
146+
if tlatex is not None:
147+
newobs.tlatex = tlatex
148+
if latex is not None:
149+
newobs.latex = latex
111150

112151
# return the clone
113152
return newobs
114-

0 commit comments

Comments
 (0)