Belle II Software development
SaveHistogramsRefiner Class Reference
Inheritance diagram for SaveHistogramsRefiner:
Refiner

Public Member Functions

def __init__ (self, name=None, title=None, contact=None, description=None, check=None, lower_bound=None, upper_bound=None, bins=None, outlier_z_score=None, allow_discrete=False, stackby="", fit=None, fit_z_score=None)
 
def refine (self, harvesting_module, crops, tdirectory=None, groupby_part_name=None, groupby_value=None, **kwds)
 

Public Attributes

 name
 cached user-defined name for this histogram
 
 title
 cached user-defined title for this histogram
 
 description
 cached user-defined description for this histogram
 
 check
 cached user-defined user-check action for this histogram
 
 contact
 cached user-defined contact person for this histogram
 
 lower_bound
 cached lower bound for this histogram
 
 upper_bound
 cached upper bound for this histogram
 
 bins
 cached number of bins for this histogram
 
 outlier_z_score
 cached Z-score (for outlier detection) for this histogram
 
 allow_discrete
 cached flag to allow discrete values for this histogram
 
 stackby
 cached stacking selection for this histogram
 
 fit
 cached fit for this histogram
 
 fit_z_score
 cached fit Z-score (for outlier detection) for this histogram
 

Static Public Attributes

str default_name = "{module.id}_{part_name}_histogram{groupby_key}{stackby_key}"
 default name for this histogram
 
str default_title = "Histogram of {part_name}{groupby_key}{stackby_key} from {module.title}"
 default title for this histogram
 
str default_contact = "{module.contact}"
 default contact person for this histogram
 
str default_description = "This is a histogram of {part_name}{groupby_key}{stackby_key}."
 default description for this histogram
 
str default_check = "Check if the distribution is reasonable"
 default user-check action for this histogram
 

Detailed Description

Refiner for histograms

Definition at line 180 of file refiners.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name = None,
  title = None,
  contact = None,
  description = None,
  check = None,
  lower_bound = None,
  upper_bound = None,
  bins = None,
  outlier_z_score = None,
  allow_discrete = False,
  stackby = "",
  fit = None,
  fit_z_score = None 
)
Constructor for this refiner

Reimplemented from Refiner.

Definition at line 193 of file refiners.py.

206 fit_z_score=None):
207 """Constructor for this refiner"""
208
209 super().__init__()
210
211
212 self.name = name
213
214 self.title = title
215
216
217 self.description = description
218
219 self.check = check
220
221 self.contact = contact
222
223
224 self.lower_bound = lower_bound
225
226 self.upper_bound = upper_bound
227
228 self.bins = bins
229
230
231 self.outlier_z_score = outlier_z_score
232
233 self.allow_discrete = allow_discrete
234
235 self.stackby = stackby
236
237
238 self.fit = fit
239
240 self.fit_z_score = fit_z_score
241

Member Function Documentation

◆ refine()

def refine (   self,
  harvesting_module,
  crops,
  tdirectory = None,
  groupby_part_name = None,
  groupby_value = None,
**  kwds 
)
Process the histogram

Reimplemented from Refiner.

Definition at line 242 of file refiners.py.

248 **kwds):
249 """Process the histogram"""
250
251 stackby = self.stackby
252 if stackby:
253 stackby_parts = crops[stackby]
254 else:
255 stackby_parts = None
256
257 replacement_dict = dict(
258 refiner=self,
259 module=harvesting_module,
260 stackby_key=' stacked by ' + stackby if stackby else "",
261 groupby_key=' in group ' + groupby_part_name + groupby_value if groupby_part_name else "",
262 )
263
264 contact = self.contact or self.default_contact
265 contact = formatter.format(contact, **replacement_dict)
266
267 for part_name, parts in iter_items_sorted_for_key(crops):
268 name = self.name or self.default_name
269 title = self.title or self.default_title
270 description = self.description or self.default_description
271 check = self.check or self.default_check
272
273 name = formatter.format(name, part_name=part_name, **replacement_dict)
274 title = formatter.format(title, part_name=part_name, **replacement_dict)
275 description = formatter.format(description, part_name=part_name, **replacement_dict)
276 check = formatter.format(check, part_name=part_name, **replacement_dict)
277
278 histogram = ValidationPlot(name)
279 histogram.hist(parts,
280 lower_bound=self.lower_bound,
281 upper_bound=self.upper_bound,
282 bins=self.bins,
283 outlier_z_score=self.outlier_z_score,
284 allow_discrete=self.allow_discrete,
285 stackby=stackby_parts)
286
287 histogram.title = title
288 histogram.contact = contact
289 histogram.description = description
290 histogram.check = check
291
292 histogram.xlabel = compose_axis_label(part_name)
293
294 if self.fit:
295 if self.fit_z_score is None:
296 kwds = dict()
297 else:
298 kwds = dict(z_score=self.fit_z_score)
299
300 fit_method_name = 'fit_' + str(self.fit)
301 try:
302 fit_method = getattr(histogram, fit_method_name)
303 except AttributeError:
304 histogram.fit(str(self.fit), **kwds)
305 else:
306 fit_method(**kwds)
307
308 if tdirectory:
309 histogram.write(tdirectory)
310
311

Member Data Documentation

◆ allow_discrete

allow_discrete

cached flag to allow discrete values for this histogram

Definition at line 233 of file refiners.py.

◆ bins

bins

cached number of bins for this histogram

Definition at line 228 of file refiners.py.

◆ check

check

cached user-defined user-check action for this histogram

Definition at line 219 of file refiners.py.

◆ contact

contact

cached user-defined contact person for this histogram

Definition at line 221 of file refiners.py.

◆ default_check

str default_check = "Check if the distribution is reasonable"
static

default user-check action for this histogram

Definition at line 191 of file refiners.py.

◆ default_contact

str default_contact = "{module.contact}"
static

default contact person for this histogram

Definition at line 187 of file refiners.py.

◆ default_description

str default_description = "This is a histogram of {part_name}{groupby_key}{stackby_key}."
static

default description for this histogram

Definition at line 189 of file refiners.py.

◆ default_name

str default_name = "{module.id}_{part_name}_histogram{groupby_key}{stackby_key}"
static

default name for this histogram

Definition at line 183 of file refiners.py.

◆ default_title

str default_title = "Histogram of {part_name}{groupby_key}{stackby_key} from {module.title}"
static

default title for this histogram

Definition at line 185 of file refiners.py.

◆ description

description

cached user-defined description for this histogram

Definition at line 217 of file refiners.py.

◆ fit

fit

cached fit for this histogram

Definition at line 238 of file refiners.py.

◆ fit_z_score

fit_z_score

cached fit Z-score (for outlier detection) for this histogram

Definition at line 240 of file refiners.py.

◆ lower_bound

lower_bound

cached lower bound for this histogram

Definition at line 224 of file refiners.py.

◆ name

name

cached user-defined name for this histogram

Definition at line 212 of file refiners.py.

◆ outlier_z_score

outlier_z_score

cached Z-score (for outlier detection) for this histogram

Definition at line 231 of file refiners.py.

◆ stackby

stackby

cached stacking selection for this histogram

Definition at line 235 of file refiners.py.

◆ title

title

cached user-defined title for this histogram

Definition at line 214 of file refiners.py.

◆ upper_bound

upper_bound

cached upper bound for this histogram

Definition at line 226 of file refiners.py.


The documentation for this class was generated from the following file: