"mmdet/apis/train.py" did not exist on "0b031a807caac178d29f9b2c8626066c35a7b5a7"
Implementation and documentation of max_lt/mix_gt is out of sync or contradictory
The documentation of max_lt
and min_gt
imply a different behavior ("None is returned if seq was empty or all items in seq were >= val." see https://gitlab.aicrowd.com/flatland/baselines/blob/master/utils/observation_utils.py).
For max_lt
I would expect the following to pass, but it does not:
>>> # Failure cases:
>>> # None is not returned
>>> print(max_lt([], 0.5))
None
>>> # None is not returned
>>> print(max_lt([1.0], 0.5))
None
>>> # negative values in seq are ignored
>>> max_lt([-1.0], 0)
-1.0
min_gt
has the same failure cases.
The implementation of both functions could be simpler and more robust. Something like this:
def max_lt(seq, val):
try:
return max(x for x in seq if x < val)
except ValueError:
return None
def min_gt(seq, val):
try:
return min(x for x in seq if x > val)
except ValueError:
return None