def better(old_value, new_value, mode):
if (old_value is None or np.isnan(old_value)) and (new_value is not None and not np.isnan(new_value)):<EOL><INDENT>return True<EOL><DEDENT>if mode == '<STR_LIT>':<EOL><INDENT>return new_value < old_value<EOL><DEDENT>elif mode == '<STR_LIT>':<EOL><INDENT>return new_value > old_value<EOL><DEDENT>else:<EOL><INDENT>raise RuntimeError(f"<STR_LIT>")<EOL><DEDENT>
Check if new value is better than the old value