"""
Box class

Medical Images 2021- MUEI/MNUR ETSEIB
"""
from copy import copy


class Box:
    def __init__(self, xmin, ymin, xmax, ymax):
        self.xmin = xmin
        self.ymin = ymin
        self.xmax = xmax
        self.ymax = ymax

    @property
    def width(self):
        return self.xmax - self.xmin

    @property
    def height(self):
        return self.ymax - self.ymin

    def aspect_ratio(self):
        return self.width / self.height

    def __str__(self):
        return "({:.2f}, {:.2f}, {:.2f}, {:.2f})".format(
            self.xmin, self.ymin, self.xmax, self.ymax
        )

    def fitting_window(self, asp):
        """
        To be implemented.
        Given an aspect ratio it returns the smallest possible centered box
        that encloses self but fits the aspect ratio. To do so, it adds margins
        at top and bottom or right and left to get the desired aspect ratio
        """
        pass
