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

Method _check_parameters

pyfair/model/model_input.py:85–107  ·  view source on GitHub ↗

Runs parameter checks This includes a determination that the value is equal to or greater than zero, and a check that all required keywords for a given

(self, target_function, **kwargs)

Source from the content-addressed store, hash-verified

83 raise FairException('"{}" must have "{}" value between zero and one.'.format(target, key))
84
85 def _check_parameters(self, target_function, **kwargs):
86 """Runs parameter checks
87
88 This includes a determination that the value is equal to or
89 greater than zero, and a check that all required keywords for a
90 given
91
92 """
93 # Ensure all arguments are =< 0 where relevant
94 for keyword, value in kwargs.items():
95 # Two conditions
96 value_is_less_than_zero = value < 0
97 keyword_is_relevant = keyword in ['mean', 'constant', 'low', 'mode', 'high']
98 # Test conditions
99 if keyword_is_relevant and value_is_less_than_zero:
100 raise FairException('"{}" is less than zero.'.format(keyword))
101 # Check that all required keywords are provided
102 required_keywords = self._required_keywords[target_function]
103 for required_keyword in required_keywords:
104 if required_keyword in kwargs.keys():
105 pass
106 else:
107 raise FairException('"{}" is missing "{}".'.format(str(target_function), required_keyword))
108
109 def generate(self, target, count, **kwargs):
110 """Executes request, records parameters, and return random values

Callers 2

_generate_singleMethod · 0.95
test_check_parametersMethod · 0.80

Calls 1

FairExceptionClass · 0.85

Tested by 1

test_check_parametersMethod · 0.64