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

Public Member Functions

 __init__ (self, name=None, title=None, contact=None, description=None, check=None, key=None, aggregation=None)
 
 refine (self, harvesting_module, crops, tdirectory=None, groupby_part_name=None, groupby_value=None, **kwds)
 
 __get__ (self, harvesting_module, cls=None)
 
 __call__ (self, harvesting_module, crops=None, *args, **kwds)
 

Static Public Member Functions

 mean (xs)
 return the mean of the parts, ignoring NaNs
 

Public Attributes

 name = name
 cached name of the figure of merit
 
 title = title
 cached title of the figure of merit
 
 description = description
 cached description of the figure of merit
 
 check = check
 cached user-check action of the figure of merit
 
 contact = contact
 cached contact person of the figure of merit
 
 key = key
 cached copy of the figures-of-merit key
 
 aggregation = aggregation
 cached copy of the crops-aggregation method
 
 refiner_function = refiner_function
 cached copy of the instance's refiner function
 

Static Public Attributes

str default_name = "{module.id}_figures_of_merit{groupby_key}"
 default name for this refiner
 
str default_title = "Figures of merit in {module.title}"
 default title for this refiner
 
str default_contact = "{module.contact}"
 default contact person for this refiner
 
str default_description = "Figures of merit are the {aggregation.__name__} of {keys}"
 default description for this refiner
 
str default_check = "Check for reasonable values"
 default user-check action for this refiner
 
str default_key = "{aggregation.__name__}_{part_name}"
 default key name for this refiner
 
 default_aggregation = mean
 default aggregation is the mean of the parts
 

Detailed Description

Refiner for figures of merit

Definition at line 74 of file refiners.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
name = None,
title = None,
contact = None,
description = None,
check = None,
key = None,
aggregation = None )
Constructor for this refiner

Definition at line 97 of file refiners.py.

105 ):
106 """Constructor for this refiner"""
107
108 super().__init__()
109
110 ## cached name of the figure of merit
111 self.name = name
112 ## cached title of the figure of merit
113 self.title = title
114
115 ## cached description of the figure of merit
116 self.description = description
117 ## cached user-check action of the figure of merit
118 self.check = check
119 ## cached contact person of the figure of merit
120 self.contact = contact
121
122 ## cached copy of the figures-of-merit key
123 self.key = key
124 ## cached copy of the crops-aggregation method
125 self.aggregation = aggregation
126

Member Function Documentation

◆ __call__()

__call__ ( self,
harvesting_module,
crops = None,
* args,
** kwds )
inherited
implementation of the function-call of the Refiner instance r = Refiner() r(harvester) # decoration r(harvester, crops, args, keywords) # refinement

Definition at line 55 of file refiners.py.

55 def __call__(self, harvesting_module, crops=None, *args, **kwds):
56 """implementation of the function-call of the Refiner instance
57 r = Refiner()
58 r(harvester) # decoration
59 r(harvester, crops, args, keywords) # refinement
60 """
61 if crops is None:
62 # Decoration mode
63 harvesting_module.refiners.append(self)
64 return harvesting_module
65 else:
66 # Refining mode
67 return self.refine(harvesting_module, crops, *args, **kwds)
68

◆ __get__()

__get__ ( self,
harvesting_module,
cls = None )
inherited
Getter of the Refiner instance

Definition at line 42 of file refiners.py.

42 def __get__(self, harvesting_module, cls=None):
43 """Getter of the Refiner instance"""
44 if harvesting_module is None:
45 # Class access
46 return self
47 else:
48 # Instance access
49 refine = self.refine
50
51 def bound_call(*args, **kwds):
52 return refine(harvesting_module, *args, **kwds)
53 return bound_call
54

◆ mean()

mean ( xs)
static

return the mean of the parts, ignoring NaNs

Definition at line 91 of file refiners.py.

91 def mean(xs):
92 return np.nanmean(xs)
93

◆ refine()

refine ( self,
harvesting_module,
crops,
tdirectory = None,
groupby_part_name = None,
groupby_value = None,
** kwds )
Process the figures of merit

Reimplemented from Refiner.

Definition at line 127 of file refiners.py.

133 **kwds):
134 """Process the figures of merit"""
135
136 name = self.name or self.default_name
137 title = self.title or self.default_title
138 contact = self.contact or self.default_contact
139 description = self.description or self.default_description
140 check = self.check or self.default_check
141
142 aggregation = self.aggregation or self.default_aggregation
143
144 replacement_dict = dict(
145 refiner=self,
146 module=harvesting_module,
147 aggregation=aggregation,
148 groupby_key='_' + groupby_part_name + groupby_value if groupby_part_name else "",
149 groupby=groupby_part_name, # deprecated
150 groupby_value=groupby_value, # deprecated
151 )
152
153 name = formatter.format(name, **replacement_dict)
154 title = formatter.format(title, **replacement_dict)
155 contact = formatter.format(contact, **replacement_dict)
156
157 figures_of_merit = ValidationFiguresOfMerit(name,
158 contact=contact,
159 title=title)
160
161 for part_name, parts in iter_items_sorted_for_key(crops):
162 key = self.key or self.default_key
163 key = formatter.format(key, part_name=part_name, **replacement_dict)
164 figures_of_merit[key] = aggregation(parts)
165
166 keys = list(figures_of_merit.keys())
167
168 description = formatter.format(description, keys=keys, **replacement_dict)
169 check = formatter.format(check, keys=keys, **replacement_dict)
170
171 figures_of_merit.description = description
172 figures_of_merit.check = check
173
174 if tdirectory:
175 figures_of_merit.write(tdirectory)
176
177 print(figures_of_merit)
178
179

Member Data Documentation

◆ aggregation

aggregation = aggregation

cached copy of the crops-aggregation method

Definition at line 125 of file refiners.py.

◆ check

check = check

cached user-check action of the figure of merit

Definition at line 118 of file refiners.py.

◆ contact

contact = contact

cached contact person of the figure of merit

Definition at line 120 of file refiners.py.

◆ default_aggregation

default_aggregation = mean
static

default aggregation is the mean of the parts

Definition at line 95 of file refiners.py.

◆ default_check

str default_check = "Check for reasonable values"
static

default user-check action for this refiner

Definition at line 85 of file refiners.py.

◆ default_contact

str default_contact = "{module.contact}"
static

default contact person for this refiner

Definition at line 81 of file refiners.py.

◆ default_description

str default_description = "Figures of merit are the {aggregation.__name__} of {keys}"
static

default description for this refiner

Definition at line 83 of file refiners.py.

◆ default_key

str default_key = "{aggregation.__name__}_{part_name}"
static

default key name for this refiner

Definition at line 87 of file refiners.py.

◆ default_name

str default_name = "{module.id}_figures_of_merit{groupby_key}"
static

default name for this refiner

Definition at line 77 of file refiners.py.

◆ default_title

str default_title = "Figures of merit in {module.title}"
static

default title for this refiner

Definition at line 79 of file refiners.py.

◆ description

description = description

cached description of the figure of merit

Definition at line 116 of file refiners.py.

◆ key

key = key

cached copy of the figures-of-merit key

Definition at line 123 of file refiners.py.

◆ name

name = name

cached name of the figure of merit

Definition at line 111 of file refiners.py.

◆ refiner_function

refiner_function = refiner_function
inherited

cached copy of the instance's refiner function

Definition at line 40 of file refiners.py.

◆ title

title = title

cached title of the figure of merit

Definition at line 113 of file refiners.py.


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