MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / _validate_not_empty

Function _validate_not_empty

dynamic_programming/viterbi.py:217–245  ·  view source on GitHub ↗

>>> _validate_not_empty(["a"], ["b"], {"c":0.5}, ... {"d": {"e": 0.6}}, {"f": {"g": 0.7}}) >>> _validate_not_empty(["a"], ["b"], {"c":0.5}, {}, {"f": {"g": 0.7}}) Traceback (most recent call last): ... ValueError: There's an empty parameter >>> _validate_not_empt

(
    observations_space: Any,
    states_space: Any,
    initial_probabilities: Any,
    transition_probabilities: Any,
    emission_probabilities: Any,
)

Source from the content-addressed store, hash-verified

215
216
217def _validate_not_empty(
218 observations_space: Any,
219 states_space: Any,
220 initial_probabilities: Any,
221 transition_probabilities: Any,
222 emission_probabilities: Any,
223) -> None:
224 """
225 >>> _validate_not_empty(["a"], ["b"], {"c":0.5},
226 ... {"d": {"e": 0.6}}, {"f": {"g": 0.7}})
227 >>> _validate_not_empty(["a"], ["b"], {"c":0.5}, {}, {"f": {"g": 0.7}})
228 Traceback (most recent call last):
229 ...
230 ValueError: There's an empty parameter
231 >>> _validate_not_empty(["a"], ["b"], None, {"d": {"e": 0.6}}, {"f": {"g": 0.7}})
232 Traceback (most recent call last):
233 ...
234 ValueError: There's an empty parameter
235 """
236 if not all(
237 [
238 observations_space,
239 states_space,
240 initial_probabilities,
241 transition_probabilities,
242 emission_probabilities,
243 ]
244 ):
245 raise ValueError("There's an empty parameter")
246
247
248def _validate_lists(observations_space: Any, states_space: Any) -> None:

Callers 1

_validationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected