class Rectangle:
def __init__(self, xmin, xmax):
if xmin is None and xmax is None:
raise Exception("At least one of xmin and xmax must be not None")
if xmin is not None and not isinstance(xmin, list):
raise Exception("xmin is neither None nor a list")
if xmax is not None and not isinstance(xmax, list):
raise Exception("xmax is neither None nor a list")
if xmin is not None and xmax is not None:
if len(xmin) != len(xmax):
raise Exception("xmin and xmax must have equal lengths")
for (xmin_element, xmax_element) in zip(xmin, xmax):
if xmin_element > xmax_element:
raise Exception("xmin must be <= xmax")
self.__xmin = None if xmin is None else [float(i) for i in xmin]
self.__xmax = None if xmax is None else [float(i) for i in xmax]
@property
def xmin(self):
return self.__xmin
@property
def xmax(self):
return self.__xmax