MCPcopy Create free account
hub / github.com/Derive-Risk/pyfair / _generate_single

Method _generate_single

pyfair/model/model_input.py:155–179  ·  view source on GitHub ↗

Internal workhorse function for single request Where applicable this includes a check that parameters are less than or equal to one, determines the appropriate RNG funtion, checks the parameters for that function, clips the value range of the result of the RNG functi

(self, target, count, **kwargs)

Source from the content-addressed store, hash-verified

153 return result
154
155 def _generate_single(self, target, count, **kwargs):
156 """Internal workhorse function for single request
157
158 Where applicable this includes a check that parameters are less
159 than or equal to one, determines the appropriate RNG funtion,
160 checks the parameters for that function, clips the value range
161 of the result of the RNG function, and returns the result.
162
163 """
164 # If destined for a le_1_target, check validity.
165 if target in self._le_1_targets:
166 self._check_le_1(target, **kwargs)
167 # Otherwise figure out what function
168 func = self._determine_func(**kwargs)
169 # Check to make sure sufficient parameters exist
170 self._check_parameters(func, **kwargs)
171 # Run the function
172 results = func(count, **kwargs)
173 # Clip if in le_1_targets
174 if target in self._le_1_targets:
175 results = np.clip(results, 0.0, 1.0)
176 # Otherwise ensure simply above zero
177 else:
178 results = np.clip(results, 0.0, np.inf)
179 return results
180
181 def generate_multi(self, prefixed_target, count, kwargs_dict):
182 """Generates aggregate risk data for multiple targets

Callers 2

generateMethod · 0.95
generate_multiMethod · 0.95

Calls 3

_check_le_1Method · 0.95
_determine_funcMethod · 0.95
_check_parametersMethod · 0.95

Tested by

no test coverage detected