I have a series of checks that I need to work with sensor data, all checks are independent, so they can not be formatted as elifs or elses, if any checks are not performed, I need to print this for the user. If none of the checks are complete, I want to tell the user that the sensor is OK
(i is just an iterator going through all the sensors in the array)
if worst_stdev[i] > 5:
print("Sensor bad, STDEV VALUE: {}".format(worst_stdev[i]))
if worst_invalid[i] > 2:
print("Sensor bad, INVALID VALUE: {}".format(worst_invalid[i]))
if worst_err[i] > 1:
print("Sensor bad, ERROR VALUE: {}".format(worst_bit_err[i]))
if not (worst_stdev[i] > 5 or worst_invalid[i] > 2 or worst_err[i] > 1):
print("Sensor OK")
Last, if the operator bothers me the most, he feels superfluous (and perhaps slower?) To check again all the things that I have already checked. Is there a good way to make this more elegant?
source
share