Skip to content

API Reference: Enums

Planet Enum

PlanetCode = Literal['EMPTY', 'AS', 'SU', 'MO', 'MA', 'ME', 'JU', 'VE', 'SA', 'RA', 'KE'] module-attribute

Planets

Bases: IntEnum

Enum to hold planets.

Source code in ndastro_engine/planet_enum.py
class Planets(IntEnum):
    """Enum to hold planets."""

    EMPTY = -1
    ASCENDANT = 0
    SUN = 1
    MOON = 2
    MARS = 3
    MERCURY = 4
    JUPITER = 5
    VENUS = 6
    SATURN = 7
    RAHU = 8
    KETHU = 9

    @staticmethod
    def to_string(num: int) -> str:
        """Convert planet number to display name of the planet.

        Args:
            num (int): the planet number

        Returns:
            str: return the planet name

        """
        return Planets(num).name if num in Planets._value2member_map_ else "empty"

    @staticmethod
    def from_astronomical_code(code: AstronomicalCode) -> "Planets":
        """Convert planet's astronomical code to planet enum.

        Args:
            code (AstronomicalCode): the planet's astronomical code

        Returns:
            Planets: the corresponding planet enum

        """
        planet_codes = {
            "empty": Planets.EMPTY,
            "ascendant": Planets.ASCENDANT,
            "sun": Planets.SUN,
            "moon": Planets.MOON,
            "mars barycenter": Planets.MARS,
            "mercury": Planets.MERCURY,
            "jupiter barycenter": Planets.JUPITER,
            "venus": Planets.VENUS,
            "saturn barycenter": Planets.SATURN,
            "rahu": Planets.RAHU,
            "kethu": Planets.KETHU,
        }

        return planet_codes.get(code, Planets.EMPTY)

    @staticmethod
    def from_code(code: PlanetCode) -> "Planets":
        """Convert planet code to planet enum.

        Args:
            code (PlanetCode): the planet code

        Returns:
            Planets: the corresponding planet enum

        """
        planet_codes = {
            "EMPTY": Planets.EMPTY,
            "AS": Planets.ASCENDANT,
            "SU": Planets.SUN,
            "MO": Planets.MOON,
            "MA": Planets.MARS,
            "ME": Planets.MERCURY,
            "JU": Planets.JUPITER,
            "VE": Planets.VENUS,
            "SA": Planets.SATURN,
            "RA": Planets.RAHU,
            "KE": Planets.KETHU,
        }

        return planet_codes.get(code, Planets.EMPTY)

    @staticmethod
    def to_list() -> list[str]:
        """Convert planet enum to list of planet name.

        Returns:
            list[str]: list of planet names

        """
        return [el.name for el in Planets]

    @property
    def code(self) -> PlanetCode:
        """Return the planet code.

        Returns:
            PlanetCode: the planet code

        """
        planet_codes = {
            Planets.EMPTY: "EMPTY",
            Planets.ASCENDANT: "AS",
            Planets.SUN: "SU",
            Planets.MOON: "MO",
            Planets.MARS: "MA",
            Planets.MERCURY: "ME",
            Planets.JUPITER: "JU",
            Planets.VENUS: "VE",
            Planets.SATURN: "SA",
            Planets.RAHU: "RA",
            Planets.KETHU: "KE",
        }

        return cast("PlanetCode", planet_codes.get(self, "EMPTY"))

    @property
    def astronomical_code(self) -> AstronomicalCode:
        """Return the astronomical code for the planet.

        Returns:
            AstronomicalCode: the astronomical code for the planet

        """
        astronomical_codes = {
            Planets.EMPTY: "empty",
            Planets.ASCENDANT: "ascendant",
            Planets.SUN: "sun",
            Planets.MOON: "moon",
            Planets.MARS: "mars barycenter",
            Planets.MERCURY: "mercury",
            Planets.JUPITER: "jupiter barycenter",
            Planets.VENUS: "venus",
            Planets.SATURN: "saturn barycenter",
            Planets.RAHU: "rahu",
            Planets.KETHU: "kethu",
        }

        return cast("AstronomicalCode", astronomical_codes.get(self, "empty"))

    @property
    def color(self) -> str:
        """Return the planet color code.

        Returns:
            str: the planet color code

        """
        planet_colors = {
            Planets.EMPTY: "#000000",  # Black
            Planets.ASCENDANT: "#FFFFFF",  # White
            Planets.SUN: "#FFD700",  # Gold
            Planets.MOON: "#C0C0C0",  # Silver
            Planets.MARS: "#FF0000",  # Red
            Planets.MERCURY: "#008000",  # Green
            Planets.JUPITER: "#FFFF00",  # Yellow
            Planets.VENUS: "#FF69B4",  # Pink
            Planets.SATURN: "#00008B",  # DarkBlue
            Planets.RAHU: "#8A2BE2",  # BlueViolet
            Planets.KETHU: "#8B0000",  # DarkRed
        }

        return planet_colors.get(self, "#000000")  # Default to Black

astronomical_code property

Return the astronomical code for the planet.

Returns:

Name Type Description
AstronomicalCode AstronomicalCode

the astronomical code for the planet

code property

Return the planet code.

Returns:

Name Type Description
PlanetCode PlanetCode

the planet code

color property

Return the planet color code.

Returns:

Name Type Description
str str

the planet color code

from_astronomical_code(code) staticmethod

Convert planet's astronomical code to planet enum.

Parameters:

Name Type Description Default
code AstronomicalCode

the planet's astronomical code

required

Returns:

Name Type Description
Planets Planets

the corresponding planet enum

Source code in ndastro_engine/planet_enum.py
@staticmethod
def from_astronomical_code(code: AstronomicalCode) -> "Planets":
    """Convert planet's astronomical code to planet enum.

    Args:
        code (AstronomicalCode): the planet's astronomical code

    Returns:
        Planets: the corresponding planet enum

    """
    planet_codes = {
        "empty": Planets.EMPTY,
        "ascendant": Planets.ASCENDANT,
        "sun": Planets.SUN,
        "moon": Planets.MOON,
        "mars barycenter": Planets.MARS,
        "mercury": Planets.MERCURY,
        "jupiter barycenter": Planets.JUPITER,
        "venus": Planets.VENUS,
        "saturn barycenter": Planets.SATURN,
        "rahu": Planets.RAHU,
        "kethu": Planets.KETHU,
    }

    return planet_codes.get(code, Planets.EMPTY)

from_code(code) staticmethod

Convert planet code to planet enum.

Parameters:

Name Type Description Default
code PlanetCode

the planet code

required

Returns:

Name Type Description
Planets Planets

the corresponding planet enum

Source code in ndastro_engine/planet_enum.py
@staticmethod
def from_code(code: PlanetCode) -> "Planets":
    """Convert planet code to planet enum.

    Args:
        code (PlanetCode): the planet code

    Returns:
        Planets: the corresponding planet enum

    """
    planet_codes = {
        "EMPTY": Planets.EMPTY,
        "AS": Planets.ASCENDANT,
        "SU": Planets.SUN,
        "MO": Planets.MOON,
        "MA": Planets.MARS,
        "ME": Planets.MERCURY,
        "JU": Planets.JUPITER,
        "VE": Planets.VENUS,
        "SA": Planets.SATURN,
        "RA": Planets.RAHU,
        "KE": Planets.KETHU,
    }

    return planet_codes.get(code, Planets.EMPTY)

to_list() staticmethod

Convert planet enum to list of planet name.

Returns:

Type Description
list[str]

list[str]: list of planet names

Source code in ndastro_engine/planet_enum.py
@staticmethod
def to_list() -> list[str]:
    """Convert planet enum to list of planet name.

    Returns:
        list[str]: list of planet names

    """
    return [el.name for el in Planets]

to_string(num) staticmethod

Convert planet number to display name of the planet.

Parameters:

Name Type Description Default
num int

the planet number

required

Returns:

Name Type Description
str str

return the planet name

Source code in ndastro_engine/planet_enum.py
@staticmethod
def to_string(num: int) -> str:
    """Convert planet number to display name of the planet.

    Args:
        num (int): the planet number

    Returns:
        str: return the planet name

    """
    return Planets(num).name if num in Planets._value2member_map_ else "empty"

House Enum

HouseCode = Literal['H1', 'H2', 'H3', 'H4', 'H5', 'H6', 'H7', 'H8', 'H9', 'H10', 'H11', 'H12'] module-attribute

Houses

Bases: IntEnum

Enum to hold houses.

Source code in ndastro_engine/house_enum.py
class Houses(IntEnum):
    """Enum to hold houses."""

    HOUSE1 = 1
    HOUSE2 = 2
    HOUSE3 = 3
    HOUSE4 = 4
    HOUSE5 = 5
    HOUSE6 = 6
    HOUSE7 = 7
    HOUSE8 = 8
    HOUSE9 = 9
    HOUSE10 = 10
    HOUSE11 = 11
    HOUSE12 = 12

    def __str__(self) -> str:
        """Return name of the house.

        Returns:
            str: name of the house

        """
        return self.name

    @property
    def owner(self) -> Planets:
        """Get the owner of a given house.

        Returns:
            Planets: The owner of the house.

        """
        house_to_planet = {
            1: Planets.MARS,
            2: Planets.VENUS,
            3: Planets.MERCURY,
            4: Planets.MOON,
            5: Planets.SUN,
            6: Planets.MERCURY,
            7: Planets.VENUS,
            8: Planets.MARS,
            9: Planets.JUPITER,
            10: Planets.SATURN,
            11: Planets.SATURN,
            12: Planets.JUPITER,
        }
        return house_to_planet[self.value]

    @property
    def code(self) -> HouseCode:
        """Get the astronomical code for a given house.

        Returns:
            HouseCode: The astronomical code for the house.

        """
        house_codes = {
            1: "H01",
            2: "H02",
            3: "H03",
            4: "H04",
            5: "H05",
            6: "H06",
            7: "H07",
            8: "H08",
            9: "H09",
            10: "H10",
            11: "H11",
            12: "H12",
        }
        return cast("HouseCode", house_codes[self.value])

    @staticmethod
    def from_code(code: HouseCode) -> "Houses":
        """Convert house code to house enum.

        Args:
            code (HouseCode): the house code

        Returns:
            Houses: the corresponding house enum

        """
        house_codes = {
            "H01": Houses.HOUSE1,
            "H02": Houses.HOUSE2,
            "H03": Houses.HOUSE3,
            "H04": Houses.HOUSE4,
            "H05": Houses.HOUSE5,
            "H06": Houses.HOUSE6,
            "H07": Houses.HOUSE7,
            "H08": Houses.HOUSE8,
            "H09": Houses.HOUSE9,
            "H10": Houses.HOUSE10,
            "H11": Houses.HOUSE11,
            "H12": Houses.HOUSE12,
        }
        return house_codes.get(code, Houses.HOUSE1)

code property

Get the astronomical code for a given house.

Returns:

Name Type Description
HouseCode HouseCode

The astronomical code for the house.

owner property

Get the owner of a given house.

Returns:

Name Type Description
Planets Planets

The owner of the house.

__str__()

Return name of the house.

Returns:

Name Type Description
str str

name of the house

Source code in ndastro_engine/house_enum.py
def __str__(self) -> str:
    """Return name of the house.

    Returns:
        str: name of the house

    """
    return self.name

from_code(code) staticmethod

Convert house code to house enum.

Parameters:

Name Type Description Default
code HouseCode

the house code

required

Returns:

Name Type Description
Houses Houses

the corresponding house enum

Source code in ndastro_engine/house_enum.py
@staticmethod
def from_code(code: HouseCode) -> "Houses":
    """Convert house code to house enum.

    Args:
        code (HouseCode): the house code

    Returns:
        Houses: the corresponding house enum

    """
    house_codes = {
        "H01": Houses.HOUSE1,
        "H02": Houses.HOUSE2,
        "H03": Houses.HOUSE3,
        "H04": Houses.HOUSE4,
        "H05": Houses.HOUSE5,
        "H06": Houses.HOUSE6,
        "H07": Houses.HOUSE7,
        "H08": Houses.HOUSE8,
        "H09": Houses.HOUSE9,
        "H10": Houses.HOUSE10,
        "H11": Houses.HOUSE11,
        "H12": Houses.HOUSE12,
    }
    return house_codes.get(code, Houses.HOUSE1)

Nakshatra Enum

NakshatraCode = Literal['N01', 'N02', 'N03', 'N04', 'N05', 'N06', 'N07', 'N08', 'N09', 'N10', 'N11', 'N12', 'N13', 'N14', 'N15', 'N16', 'N17', 'N18', 'N19', 'N20', 'N21', 'N22', 'N23', 'N24', 'N25', 'N26', 'N27'] module-attribute

Nakshatras

Bases: Enum

Enum to hold stars.

Source code in ndastro_engine/nakshatra_enum.py
class Nakshatras(Enum):
    """Enum to hold stars."""

    ASWINNI = 1
    BHARANI = 2
    KAARTHIKAI = 3
    ROGHINI = 4
    MIRUGASIRISAM = 5
    THIRUVAATHIRAI = 6
    PUNARPOOSAM = 7
    POOSAM = 8
    AAYILYAM = 9
    MAGAM = 10
    POORAM = 11
    UTHTHIRAM = 12
    ASTHTHAM = 13
    CHITHTHIRAI = 14
    SUVAATHI = 15
    VISAAGAM = 16
    ANUSHAM = 17
    KETTAI = 18
    MOOLAM = 19
    POORAADAM = 20
    UTHTHIRAADAM = 21
    THIRUVONAM = 22
    AVITTAM = 23
    SHATHAYAM = 24
    POORATTAATHI = 25
    UTHTHIRATTAATHI = 26
    REVATHI = 27

    def __str__(self) -> str:
        """Return the display name of the star.

        Returns:
            str: The display name of the star.

        """
        return self.name

    @property
    def owner(self) -> Planets:
        """Return the owner (planet) of the star.

        Returns:
            str: The name of the planet that owns the star.

        """
        owners = {
            1: "kethu",
            2: "venus",
            3: "sun",
            4: "moon",
            5: "mars barycenter",
            6: "rahu",
            7: "jupiter barycenter",
            8: "saturn barycenter",
            9: "mercury",
            10: "kethu",
            11: "venus",
            12: "sun",
            13: "moon",
            14: "mars barycenter",
            15: "rahu",
            16: "jupiter barycenter",
            17: "saturn barycenter",
            18: "mercury",
            19: "kethu",
            20: "venus",
            21: "sun",
            22: "moon",
            23: "mars barycenter",
            24: "rahu",
            25: "jupiter barycenter",
            26: "saturn barycenter",
            27: "mercury",
        }

        return Planets.from_astronomical_code(cast("AstronomicalCode", owners[self.value]))

    @property
    def code(self) -> NakshatraCode:
        """Return the astronomical code of the star.

        Returns:
            NakshatraCode: The astronomical code of the star.

        """
        nakshatra_codes = {
            Nakshatras.ASWINNI: "N01",
            Nakshatras.BHARANI: "N02",
            Nakshatras.KAARTHIKAI: "N03",
            Nakshatras.ROGHINI: "N04",
            Nakshatras.MIRUGASIRISAM: "N05",
            Nakshatras.THIRUVAATHIRAI: "N06",
            Nakshatras.PUNARPOOSAM: "N07",
            Nakshatras.POOSAM: "N08",
            Nakshatras.AAYILYAM: "N09",
            Nakshatras.MAGAM: "N10",
            Nakshatras.POORAM: "N11",
            Nakshatras.UTHTHIRAM: "N12",
            Nakshatras.ASTHTHAM: "N13",
            Nakshatras.CHITHTHIRAI: "N14",
            Nakshatras.SUVAATHI: "N15",
            Nakshatras.VISAAGAM: "N16",
            Nakshatras.ANUSHAM: "N17",
            Nakshatras.KETTAI: "N18",
            Nakshatras.MOOLAM: "N19",
            Nakshatras.POORAADAM: "N20",
            Nakshatras.UTHTHIRAADAM: "N21",
            Nakshatras.THIRUVONAM: "N22",
            Nakshatras.AVITTAM: "N23",
            Nakshatras.SHATHAYAM: "N24",
            Nakshatras.POORATTAATHI: "N25",
            Nakshatras.UTHTHIRATTAATHI: "N26",
            Nakshatras.REVATHI: "N27",
        }

        return cast("NakshatraCode", nakshatra_codes[self])

    @staticmethod
    def from_code(code: NakshatraCode) -> "Nakshatras":
        """Convert a Nakshatra code to its corresponding enum member.

        Args:
            code (NakshatraCode): The Nakshatra code.

        Returns:
            Nakshatras: The corresponding enum member.

        """
        code_to_nakshatra = {
            "N01": Nakshatras.ASWINNI,
            "N02": Nakshatras.BHARANI,
            "N03": Nakshatras.KAARTHIKAI,
            "N04": Nakshatras.ROGHINI,
            "N05": Nakshatras.MIRUGASIRISAM,
            "N06": Nakshatras.THIRUVAATHIRAI,
            "N07": Nakshatras.PUNARPOOSAM,
            "N08": Nakshatras.POOSAM,
            "N09": Nakshatras.AAYILYAM,
            "N10": Nakshatras.MAGAM,
            "N11": Nakshatras.POORAM,
            "N12": Nakshatras.UTHTHIRAM,
            "N13": Nakshatras.ASTHTHAM,
            "N14": Nakshatras.CHITHTHIRAI,
            "N15": Nakshatras.SUVAATHI,
            "N16": Nakshatras.VISAAGAM,
            "N17": Nakshatras.ANUSHAM,
            "N18": Nakshatras.KETTAI,
            "N19": Nakshatras.MOOLAM,
            "N20": Nakshatras.POORAADAM,
            "N21": Nakshatras.UTHTHIRAADAM,
            "N22": Nakshatras.THIRUVONAM,
            "N23": Nakshatras.AVITTAM,
            "N24": Nakshatras.SHATHAYAM,
            "N25": Nakshatras.POORATTAATHI,
            "N26": Nakshatras.UTHTHIRATTAATHI,
            "N27": Nakshatras.REVATHI,
        }

        return code_to_nakshatra[code]

    @staticmethod
    def to_string(num: int) -> str:
        """Convert star number to display name of the star.

        Args:
            num (int): the star number

        Returns:
            str: return the star name

        """
        return Nakshatras(num).name

    @staticmethod
    def to_list() -> list[str]:
        """Convert enum to list of enum item name.

        Returns:
            list[str]: list of enum item name

        """
        return [el.name for el in Nakshatras]

code property

Return the astronomical code of the star.

Returns:

Name Type Description
NakshatraCode NakshatraCode

The astronomical code of the star.

owner property

Return the owner (planet) of the star.

Returns:

Name Type Description
str Planets

The name of the planet that owns the star.

__str__()

Return the display name of the star.

Returns:

Name Type Description
str str

The display name of the star.

Source code in ndastro_engine/nakshatra_enum.py
def __str__(self) -> str:
    """Return the display name of the star.

    Returns:
        str: The display name of the star.

    """
    return self.name

from_code(code) staticmethod

Convert a Nakshatra code to its corresponding enum member.

Parameters:

Name Type Description Default
code NakshatraCode

The Nakshatra code.

required

Returns:

Name Type Description
Nakshatras Nakshatras

The corresponding enum member.

Source code in ndastro_engine/nakshatra_enum.py
@staticmethod
def from_code(code: NakshatraCode) -> "Nakshatras":
    """Convert a Nakshatra code to its corresponding enum member.

    Args:
        code (NakshatraCode): The Nakshatra code.

    Returns:
        Nakshatras: The corresponding enum member.

    """
    code_to_nakshatra = {
        "N01": Nakshatras.ASWINNI,
        "N02": Nakshatras.BHARANI,
        "N03": Nakshatras.KAARTHIKAI,
        "N04": Nakshatras.ROGHINI,
        "N05": Nakshatras.MIRUGASIRISAM,
        "N06": Nakshatras.THIRUVAATHIRAI,
        "N07": Nakshatras.PUNARPOOSAM,
        "N08": Nakshatras.POOSAM,
        "N09": Nakshatras.AAYILYAM,
        "N10": Nakshatras.MAGAM,
        "N11": Nakshatras.POORAM,
        "N12": Nakshatras.UTHTHIRAM,
        "N13": Nakshatras.ASTHTHAM,
        "N14": Nakshatras.CHITHTHIRAI,
        "N15": Nakshatras.SUVAATHI,
        "N16": Nakshatras.VISAAGAM,
        "N17": Nakshatras.ANUSHAM,
        "N18": Nakshatras.KETTAI,
        "N19": Nakshatras.MOOLAM,
        "N20": Nakshatras.POORAADAM,
        "N21": Nakshatras.UTHTHIRAADAM,
        "N22": Nakshatras.THIRUVONAM,
        "N23": Nakshatras.AVITTAM,
        "N24": Nakshatras.SHATHAYAM,
        "N25": Nakshatras.POORATTAATHI,
        "N26": Nakshatras.UTHTHIRATTAATHI,
        "N27": Nakshatras.REVATHI,
    }

    return code_to_nakshatra[code]

to_list() staticmethod

Convert enum to list of enum item name.

Returns:

Type Description
list[str]

list[str]: list of enum item name

Source code in ndastro_engine/nakshatra_enum.py
@staticmethod
def to_list() -> list[str]:
    """Convert enum to list of enum item name.

    Returns:
        list[str]: list of enum item name

    """
    return [el.name for el in Nakshatras]

to_string(num) staticmethod

Convert star number to display name of the star.

Parameters:

Name Type Description Default
num int

the star number

required

Returns:

Name Type Description
str str

return the star name

Source code in ndastro_engine/nakshatra_enum.py
@staticmethod
def to_string(num: int) -> str:
    """Convert star number to display name of the star.

    Args:
        num (int): the star number

    Returns:
        str: return the star name

    """
    return Nakshatras(num).name

Rasi Enum

RasiCode = Literal['R01', 'R02', 'R03', 'R04', 'R05', 'R06', 'R07', 'R08', 'R09', 'R10', 'R11', 'R12'] module-attribute

Rasis

Bases: IntEnum

Enum to represent Rasis.

Source code in ndastro_engine/rasi_enum.py
class Rasis(IntEnum):
    """Enum to represent Rasis."""

    ARIES = 1
    TAURUS = 2
    GEMINI = 3
    CANCER = 4
    LEO = 5
    VIRGO = 6
    LIBRA = 7
    SCORPIO = 8
    SAGITTARIUS = 9
    CAPRICORN = 10
    AQUARIUS = 11
    PISCES = 12

    def __str__(self) -> str:
        """Return a localized string representation of the Rasi.

        Returns:
            str: Localized name of the Rasi.

        """
        return self.name

    @property
    def owner(self) -> Planets | None:
        """Get the owner planet of a given Rasi.

        Args:
            rasi (int): The Rasi number.

        Returns:
            Planets | None: The owner planet of the Rasi or None if invalid Rasi.

        """
        rasi_to_planet = {
            1: Planets.MARS,
            2: Planets.VENUS,
            3: Planets.MERCURY,
            4: Planets.MOON,
            5: Planets.SUN,
            6: Planets.MERCURY,
            7: Planets.VENUS,
            8: Planets.MARS,
            9: Planets.JUPITER,
            10: Planets.SATURN,
            11: Planets.SATURN,
            12: Planets.JUPITER,
        }
        return rasi_to_planet[self.value]

    @property
    def code(self) -> RasiCode:
        """Get the astronomical code for a given Rasi.

        Returns:
            RasiCode: The astronomical code for the Rasi.

        """
        rasi_to_code = {
            Rasis.ARIES: "R01",
            Rasis.TAURUS: "R02",
            Rasis.GEMINI: "R03",
            Rasis.CANCER: "R04",
            Rasis.LEO: "R05",
            Rasis.VIRGO: "R06",
            Rasis.LIBRA: "R07",
            Rasis.SCORPIO: "R08",
            Rasis.SAGITTARIUS: "R09",
            Rasis.CAPRICORN: "R10",
            Rasis.AQUARIUS: "R11",
            Rasis.PISCES: "R12",
        }
        return cast("RasiCode", rasi_to_code[self])

    @staticmethod
    def from_code(code: RasiCode) -> Rasis | None:
        """Convert a Rasi code to its corresponding enum member.

        Args:
            code (RasiCode): The Rasi code.

        Returns:
            Rasis | None: The corresponding enum member or None if invalid code.

        """
        code_to_rasi = {
            "R01": Rasis.ARIES,
            "R02": Rasis.TAURUS,
            "R03": Rasis.GEMINI,
            "R04": Rasis.CANCER,
            "R05": Rasis.LEO,
            "R06": Rasis.VIRGO,
            "R07": Rasis.LIBRA,
            "R08": Rasis.SCORPIO,
            "R09": Rasis.SAGITTARIUS,
            "R10": Rasis.CAPRICORN,
            "R11": Rasis.AQUARIUS,
            "R12": Rasis.PISCES,
        }
        return code_to_rasi.get(code)

    @classmethod
    def from_string(cls, rasi: str) -> Rasis | None:
        """Convert a Rasi name to its corresponding enum member.

        Args:
            rasi (str): The name of the Rasi.

        Returns:
            Rasis | None: The corresponding enum member or None if invalid name.

        """
        try:
            return cls[rasi.upper()]
        except KeyError:
            return None

    @classmethod
    def to_string(cls) -> str:
        """Convert a Rasi enum member to its localized display name.

        Returns:
            str: Localized name of the Rasi.

        """
        return cls.name.name

    @staticmethod
    def to_list() -> list[str]:
        """Get a list of all Rasi names.

        Returns:
            list[str]: List of all Rasi names.

        """
        return [el.name for el in Rasis]

    @staticmethod
    def to_4x4list() -> list[list[str]]:
        """Get a 4x4 grid representation of Rasi names.

        Returns:
            list[list[str]]: 4x4 grid of Rasi names.

        """
        rasis = Rasis.to_list()

        return [
            [rasis[11], rasis[0], rasis[1], rasis[2]],
            [rasis[10], "", "", rasis[3]],
            [rasis[9], "", "", rasis[4]],
            [rasis[8], rasis[7], rasis[6], rasis[5]],
        ]

code property

Get the astronomical code for a given Rasi.

Returns:

Name Type Description
RasiCode RasiCode

The astronomical code for the Rasi.

owner property

Get the owner planet of a given Rasi.

Parameters:

Name Type Description Default
rasi int

The Rasi number.

required

Returns:

Type Description
Planets | None

Planets | None: The owner planet of the Rasi or None if invalid Rasi.

__str__()

Return a localized string representation of the Rasi.

Returns:

Name Type Description
str str

Localized name of the Rasi.

Source code in ndastro_engine/rasi_enum.py
def __str__(self) -> str:
    """Return a localized string representation of the Rasi.

    Returns:
        str: Localized name of the Rasi.

    """
    return self.name

from_code(code) staticmethod

Convert a Rasi code to its corresponding enum member.

Parameters:

Name Type Description Default
code RasiCode

The Rasi code.

required

Returns:

Type Description
Rasis | None

Rasis | None: The corresponding enum member or None if invalid code.

Source code in ndastro_engine/rasi_enum.py
@staticmethod
def from_code(code: RasiCode) -> Rasis | None:
    """Convert a Rasi code to its corresponding enum member.

    Args:
        code (RasiCode): The Rasi code.

    Returns:
        Rasis | None: The corresponding enum member or None if invalid code.

    """
    code_to_rasi = {
        "R01": Rasis.ARIES,
        "R02": Rasis.TAURUS,
        "R03": Rasis.GEMINI,
        "R04": Rasis.CANCER,
        "R05": Rasis.LEO,
        "R06": Rasis.VIRGO,
        "R07": Rasis.LIBRA,
        "R08": Rasis.SCORPIO,
        "R09": Rasis.SAGITTARIUS,
        "R10": Rasis.CAPRICORN,
        "R11": Rasis.AQUARIUS,
        "R12": Rasis.PISCES,
    }
    return code_to_rasi.get(code)

from_string(rasi) classmethod

Convert a Rasi name to its corresponding enum member.

Parameters:

Name Type Description Default
rasi str

The name of the Rasi.

required

Returns:

Type Description
Rasis | None

Rasis | None: The corresponding enum member or None if invalid name.

Source code in ndastro_engine/rasi_enum.py
@classmethod
def from_string(cls, rasi: str) -> Rasis | None:
    """Convert a Rasi name to its corresponding enum member.

    Args:
        rasi (str): The name of the Rasi.

    Returns:
        Rasis | None: The corresponding enum member or None if invalid name.

    """
    try:
        return cls[rasi.upper()]
    except KeyError:
        return None

to_4x4list() staticmethod

Get a 4x4 grid representation of Rasi names.

Returns:

Type Description
list[list[str]]

list[list[str]]: 4x4 grid of Rasi names.

Source code in ndastro_engine/rasi_enum.py
@staticmethod
def to_4x4list() -> list[list[str]]:
    """Get a 4x4 grid representation of Rasi names.

    Returns:
        list[list[str]]: 4x4 grid of Rasi names.

    """
    rasis = Rasis.to_list()

    return [
        [rasis[11], rasis[0], rasis[1], rasis[2]],
        [rasis[10], "", "", rasis[3]],
        [rasis[9], "", "", rasis[4]],
        [rasis[8], rasis[7], rasis[6], rasis[5]],
    ]

to_list() staticmethod

Get a list of all Rasi names.

Returns:

Type Description
list[str]

list[str]: List of all Rasi names.

Source code in ndastro_engine/rasi_enum.py
@staticmethod
def to_list() -> list[str]:
    """Get a list of all Rasi names.

    Returns:
        list[str]: List of all Rasi names.

    """
    return [el.name for el in Rasis]

to_string() classmethod

Convert a Rasi enum member to its localized display name.

Returns:

Name Type Description
str str

Localized name of the Rasi.

Source code in ndastro_engine/rasi_enum.py
@classmethod
def to_string(cls) -> str:
    """Convert a Rasi enum member to its localized display name.

    Returns:
        str: Localized name of the Rasi.

    """
    return cls.name.name