'Check that this rect is a valid bounding box within this shape.
Args:
shape: [h, w]
Returns:
bool'

def validate(self, shape=None):

    if (min(self.x, self.y) < 0):
        return False
    if (min(self.w, self.h) <= 0):
        return False
    if (shape is None):
        return True
    if (self.x1 > (shape[1] - 1)):
        return False
    if (self.y1 > (shape[0] - 1)):
        return False
    return True
