from enum import Enum


class PanelType(Enum):
    Corner = 0
    NorthSouth = 1
    EastWest = 2
    Middle = 3

    @classmethod
    def from_number(cls, number):
        if number == 1:
            return cls.Corner
        elif number == 2:
            return cls.NorthSouth
        elif number == 3:
            return cls.EastWest
        elif number == 4:
            return cls.Middle
        return None

    @classmethod
    def from_index(cls, index):
        return PanelType(index)

    @classmethod
    def all(cls):
        return [cls.Corner, cls.NorthSouth, cls.EastWest, cls.Middle]

    def number(self):
        return self.value + 1

    def index(self):
        return self.value

    def snake_case(self):
        return {
            PanelType.Corner: 'corner',
            PanelType.NorthSouth: 'north_south',
            PanelType.EastWest: 'east_west',
            PanelType.Middle: 'middle',
        }[self]

    def __sub__(self, other):  # Used for testing (assert_array_almost_equal requires subtraction)
        return self.value - other.value

