[refactor] get_quality_class uses generator expression
Can handy any size of list for weight_classes now
This commit is contained in:
parent
c38e3eb07a
commit
628f335b34
@ -1204,27 +1204,13 @@ def get_quality_class(uncertainty, weight_classes):
|
|||||||
:return: quality of pick (0-4)
|
:return: quality of pick (0-4)
|
||||||
:rtype: int
|
:rtype: int
|
||||||
"""
|
"""
|
||||||
|
try:
|
||||||
# set initial quality to 4 (worst) and change only if one condition is hit
|
# create generator expression containing all indices of values in weight classes that are >= than uncertainty.
|
||||||
quality = 4
|
# call next on it once to receive first value
|
||||||
|
quality = next(i for i, v in enumerate(weight_classes) if v >= uncertainty)
|
||||||
if real_None(uncertainty) is None:
|
except StopIteration:
|
||||||
return quality
|
# raised when uncertainty is larger than all values in weight_classes
|
||||||
|
quality = len(weight_classes)
|
||||||
if uncertainty <= Errors[0]:
|
|
||||||
quality = 0
|
|
||||||
elif (uncertainty > Errors[0]) and \
|
|
||||||
(uncertainty <= Errors[1]):
|
|
||||||
quality = 1
|
|
||||||
elif (uncertainty > Errors[1]) and \
|
|
||||||
(uncertainty <= Errors[2]):
|
|
||||||
quality = 2
|
|
||||||
elif (uncertainty > Errors[2]) and \
|
|
||||||
(uncertainty <= Errors[3]):
|
|
||||||
quality = 3
|
|
||||||
elif uncertainty > Errors[3]:
|
|
||||||
quality = 4
|
|
||||||
|
|
||||||
return quality
|
return quality
|
||||||
|
|
||||||
def set_NaNs_to(data, nan_value):
|
def set_NaNs_to(data, nan_value):
|
||||||
|
Loading…
Reference in New Issue
Block a user