Loop can be refactored to use
all
491 # is the main method to find which grid contains a given point. (method
492 # finest_component_at_point). So, it is better to have a less pythonic
493 # method that fails as soon as possible.
494 for dim in range(self.num_dimensions):495 if not (
496 self.lowest_vertex[dim]
497 <= point[dim]
Description
It is recommended to use all
for this loop, as it will make your code smaller and more readable.
Bad practice
def all_even(items):
for item in items:
if item % 2 != 0:
return False
return True
Recommended
def all_even(items):
return all(item % 2 == 0 for item in items)