from pydantic import BaseModel, model_validator


class Space(BaseModel, frozen=True):
    width: int
    height: int

    @model_validator(mode="after")
    def _validate_positive(self) -> "Space":
        if self.width <= 1 or self.height <= 1:
            raise ValueError("width and height must be greater than 1")
        return self

    @property
    def aspect_ratio(self) -> float:
        return self.width / self.height
