@@ -57,7 +57,7 @@ def func(d: Sequence[float]) -> Any:
5757
5858
5959def make_builder (
60- funcname : str , deps : list [str ], newparams : dict [str , dict [str , Sequence [float ]]]
60+ func_name : str , deps : list [str ], new_params : dict [str , dict [str , Sequence [float ]]]
6161) -> BaseBuilder :
6262 class _builder (BaseBuilder ):
6363 is_shared = False
@@ -83,13 +83,13 @@ def append(self, key, channel, sample, thismod, defined_samp):
8383 moddata = self .collect (thismod , nom )
8484 self .builder_data [key ][sample ]["data" ]["mask" ] += moddata ["mask" ]
8585 if thismod :
86- if thismod ["name" ] != funcname :
86+ if thismod ["name" ] != func_name :
8787 print (thismod )
8888 self .builder_data ["funcs" ].setdefault (
8989 thismod ["name" ], thismod ["data" ]["expr" ]
9090 )
9191 self .required_parsets = {
92- k : [_allocate_new_param (v )] for k , v in newparams .items ()
92+ k : [_allocate_new_param (v )] for k , v in new_params .items ()
9393 }
9494
9595 def finalize (self ):
@@ -99,10 +99,10 @@ def finalize(self):
9999
100100
101101def make_applier (
102- funcname : str , deps : list [str ], newparams : dict [str , dict [str , Sequence [float ]]]
102+ func_name : str , deps : list [str ], new_params : dict [str , dict [str , Sequence [float ]]]
103103) -> BaseApplier :
104104 class _applier (BaseApplier ):
105- name = funcname
105+ name = func_name
106106 op_code = "multiplication"
107107
108108 def __init__ (self , modifiers , pdfconfig , builder_data , batch_size = None ):
@@ -120,7 +120,7 @@ def __init__(self, modifiers, pdfconfig, builder_data, batch_size=None):
120120 self .param_viewer = ParamViewer (
121121 parfield_shape , pdfconfig .par_map , pars_for_applier
122122 )
123- self ._custommod_mask = [
123+ self ._custom_mod_mask = [
124124 [[builder_data [modname ][s ]["data" ]["mask" ]] for s in pdfconfig .samples ]
125125 for modname in _modnames
126126 ]
@@ -131,14 +131,14 @@ def _precompute(self):
131131 tensorlib , _ = get_backend ()
132132 if not self .param_viewer .index_selection :
133133 return
134- self .custommod_mask = tensorlib .tile (
135- tensorlib .astensor (self ._custommod_mask ),
134+ self .custom_mod_mask = tensorlib .tile (
135+ tensorlib .astensor (self ._custom_mod_mask ),
136136 (1 , 1 , self .batch_size or 1 , 1 ),
137137 )
138- self .custommod_mask_bool = tensorlib .astensor (
139- self .custommod_mask , dtype = "bool"
138+ self .custom_mod_mask_bool = tensorlib .astensor (
139+ self .custom_mod_mask , dtype = "bool"
140140 )
141- self .custommod_default = tensorlib .ones (self .custommod_mask .shape )
141+ self .custom_mod_default = tensorlib .ones (self .custom_mod_mask .shape )
142142
143143 def apply (self , pars ):
144144 """
@@ -152,27 +152,29 @@ def apply(self, pars):
152152 deps = self .param_viewer .get (pars )
153153 print ("deps" , deps .shape )
154154 results = tensorlib .astensor ([f (deps ) for f in self .funcs ])
155- results = tensorlib .einsum ("msab,m->msab" , self .custommod_mask , results )
155+ results = tensorlib .einsum (
156+ "msab,m->msab" , self .custom_mod_mask , results
157+ )
156158 else :
157159 deps = self .param_viewer .get (pars )
158160 print ("deps" , deps .shape )
159161 results = tensorlib .astensor ([f (deps ) for f in self .funcs ])
160162 results = tensorlib .einsum (
161- "msab,ma->msab" , self .custommod_mask , results
163+ "msab,ma->msab" , self .custom_mod_mask , results
162164 )
163165 results = tensorlib .where (
164- self .custommod_mask_bool , results , self .custommod_default
166+ self .custom_mod_mask_bool , results , self .custom_mod_default
165167 )
166168 return results
167169
168170 return _applier
169171
170172
171173def add_custom_modifier (
172- funcname : str , deps : list [str ], newparams : dict [str , dict [str , Sequence [float ]]]
174+ func_name : str , deps : list [str ], new_params : dict [str , dict [str , Sequence [float ]]]
173175) -> dict [str , tuple [BaseBuilder , BaseApplier ]]:
174- _builder = make_builder (funcname , deps , newparams )
175- _applier = make_applier (funcname , deps , newparams )
176+ _builder = make_builder (func_name , deps , new_params )
177+ _applier = make_applier (func_name , deps , new_params )
176178
177179 modifier_set = {_applier .name : (_builder , _applier )}
178180 modifier_set .update (** pyhf .modifiers .histfactory_set )
0 commit comments