kerykeion.relationship_score

This is part of Kerykeion (C) 2024 Giacomo Battaglia

  1# -*- coding: utf-8 -*-
  2"""
  3    This is part of Kerykeion (C) 2024 Giacomo Battaglia
  4"""
  5
  6from kerykeion import AstrologicalSubject
  7from kerykeion.aspects.synastry_aspects import SynastryAspects
  8import logging
  9from pathlib import Path
 10from typing import Union
 11
 12
 13class RelationshipScore:
 14    """
 15    Calculates the relevance of the relationship of the two subjects according to
 16    Ciro Discepolo method.
 17
 18    Results:
 19        - From 0 to 5 = Null relationship
 20        - From 5 a 10 = Mediocre relationship
 21        - From 10 to 15 = Important relationship
 22        - From 15 to 20 = Very important relationship
 23        - From 20 to su = Exceptional relationship
 24
 25    Documentation at:
 26    http://www.cirodiscepolo.it/Articoli/Discepoloele.htm
 27
 28    Args:
 29        first_subject (AstrologicalSubject): First subject kerykeion instance
 30        second_subject (AstrologicalSubject): Second subject kerykeion instance
 31
 32    """
 33
 34    first_subject: AstrologicalSubject
 35    second_subject: AstrologicalSubject
 36    score: int
 37    is_destiny_sign: bool
 38    relevant_aspects: list
 39    relevant_default_aspects: list
 40
 41    def __init__(
 42        self,
 43        first_subject: AstrologicalSubject,
 44        second_subject: AstrologicalSubject,
 45        new_settings_file: Union[Path, None] = None,
 46    ):
 47        self.first_subject = first_subject
 48        self.second_subject = second_subject
 49        self.score = 0
 50        self.is_destiny_sign = False
 51        self.relevant_aspects = []
 52        self.relevant_default_aspects = []
 53        self.__all_synastry_aspects = SynastryAspects(
 54            first_subject, second_subject, new_settings_file=new_settings_file
 55        ).all_aspects
 56
 57        # Calculates all at initialization
 58        self._get_all()
 59
 60    def __str__(self) -> str:
 61        return f"CuppleScoreInstance: {self.first_subject.name} and {self.second_subject.name}, score: {self.score}"
 62
 63    def __dict__(self):
 64        return {
 65            "first_subject_name": self.first_subject.name,
 66            "second_subject_name": self.second_subject.name,
 67            "score": self.score,
 68            "relevant_aspects": self.relevant_aspects,
 69            "relevant_default_aspects": self.relevant_default_aspects,
 70            "is_destiny_sign": self.is_destiny_sign,
 71        }
 72
 73    def _log_aspect(self, aspect: dict, points: int) -> None:
 74        logging.debug(
 75            f"{points} Points: {aspect['p1_name']} {aspect['aspect']} {aspect['p2_name']}, rounded orbit: {int(aspect['orbit'])}"
 76        )
 77
 78    def _evaluate_destiny_sign(self) -> int:
 79        """
 80        5 points if is a destiny sign:
 81        """
 82        if self.first_subject.sun["quality"] == self.second_subject.sun["quality"]:
 83            logging.debug(
 84                f'5 points: Destiny sign, {self.first_subject.sun["sign"]} and {self.second_subject.sun["sign"]}'
 85            )
 86            self.is_destiny_sign = True
 87            return 5
 88
 89        return 0
 90
 91    def _check_if_sun_sun_aspect(self, aspect: dict, log: bool = True) -> int:
 92        """
 93        8 points if Sun conjunction/opposition/square to Sun,
 94        11 if diff <= 2 degrees:
 95        """
 96        aspect_types = ["conjunction", "opposition", "square"]
 97
 98        if (aspect["p1_name"] == "Sun" and aspect["p2_name"] == "Sun") and (aspect["aspect"] in aspect_types):
 99            self.relevant_default_aspects.append(aspect)
100
101            if aspect["orbit"] <= 2:
102                score = 11
103
104                self._log_aspect(aspect, score)
105                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
106
107                return score
108            else:
109                score = 8
110
111                self._log_aspect(aspect, score)
112                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
113
114                return score
115
116        return 0
117
118    def _check_if_sun_moon_conjunction(self, aspect: dict) -> int:
119        """
120        8 points if Moon conjunction/opposition/square to Moon,
121        11 if diff <= 2 degrees:
122        """
123        planets = set(["Moon", "Sun"])
124
125        if set([aspect["p1_name"], aspect["p2_name"]]) == planets and aspect["aspect"] == "conjunction":
126            self.relevant_default_aspects.append(aspect)
127
128            if aspect["orbit"] <= 2:
129                score = 11
130
131                self._log_aspect(aspect, score)
132                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
133
134                return score
135
136            else:
137                score = 8
138
139                self._log_aspect(aspect, score)
140                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
141
142                return score
143
144        return 0
145
146    def _check_if_sun_moon_asc_aspect(self, aspect: dict) -> int:
147        planets = ["Sun", "Moon", "First_House"]
148
149        if self._check_if_sun_sun_aspect(aspect) or self._check_if_sun_moon_conjunction(aspect):
150            return 0
151
152        if aspect["p1_name"] in planets and aspect["p2_name"] in planets:
153            self.relevant_default_aspects.append(aspect)
154            score = 4
155
156            self._log_aspect(aspect, score)
157            self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
158
159            return score
160
161        return 0
162
163    def _check_if_venus_mars_aspect(self, aspect: dict) -> int:
164        planets = set(["Venus", "Mars"])
165        if set([aspect["p1_name"], aspect["p2_name"]]) == planets:
166            score = 4
167            self.relevant_default_aspects.append(aspect)
168
169            self._log_aspect(aspect, score)
170            self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
171
172            return score
173
174        return 0
175
176    def _create_aspects_dictionary(self, aspect: dict, score: int) -> dict:
177        return {
178            "points": score,
179            "p1_name": aspect["p1_name"],
180            "p2_name": aspect["p2_name"],
181            "aspect": aspect["aspect"],
182            "orbit": aspect["orbit"],
183        }
184
185    def _get_all(self) -> None:
186        self.score += self._evaluate_destiny_sign()
187
188        for a in self.__all_synastry_aspects:
189            self.score += self._check_if_sun_sun_aspect(a)
190            self.score += self._check_if_sun_moon_conjunction(a)
191            self.score += self._check_if_sun_moon_asc_aspect(a)
192            self.score += self._check_if_venus_mars_aspect(a)
193
194
195if __name__ == "__main__":
196    from kerykeion.utilities import setup_logging
197    setup_logging(level="debug")
198
199    lui = AstrologicalSubject("John", 1975, 10, 10, 21, 15, "Roma", "IT")
200    lei = AstrologicalSubject("Sarah", 1978, 2, 9, 15, 50, "Roma", "IT")
201
202    score = RelationshipScore(lui, lei)
203    print(score.__dict__()["score"])
204    print(score.__dict__()["is_destiny_sign"])
205    print(score.__dict__()["relevant_aspects"][0])
class RelationshipScore:
 14class RelationshipScore:
 15    """
 16    Calculates the relevance of the relationship of the two subjects according to
 17    Ciro Discepolo method.
 18
 19    Results:
 20        - From 0 to 5 = Null relationship
 21        - From 5 a 10 = Mediocre relationship
 22        - From 10 to 15 = Important relationship
 23        - From 15 to 20 = Very important relationship
 24        - From 20 to su = Exceptional relationship
 25
 26    Documentation at:
 27    http://www.cirodiscepolo.it/Articoli/Discepoloele.htm
 28
 29    Args:
 30        first_subject (AstrologicalSubject): First subject kerykeion instance
 31        second_subject (AstrologicalSubject): Second subject kerykeion instance
 32
 33    """
 34
 35    first_subject: AstrologicalSubject
 36    second_subject: AstrologicalSubject
 37    score: int
 38    is_destiny_sign: bool
 39    relevant_aspects: list
 40    relevant_default_aspects: list
 41
 42    def __init__(
 43        self,
 44        first_subject: AstrologicalSubject,
 45        second_subject: AstrologicalSubject,
 46        new_settings_file: Union[Path, None] = None,
 47    ):
 48        self.first_subject = first_subject
 49        self.second_subject = second_subject
 50        self.score = 0
 51        self.is_destiny_sign = False
 52        self.relevant_aspects = []
 53        self.relevant_default_aspects = []
 54        self.__all_synastry_aspects = SynastryAspects(
 55            first_subject, second_subject, new_settings_file=new_settings_file
 56        ).all_aspects
 57
 58        # Calculates all at initialization
 59        self._get_all()
 60
 61    def __str__(self) -> str:
 62        return f"CuppleScoreInstance: {self.first_subject.name} and {self.second_subject.name}, score: {self.score}"
 63
 64    def __dict__(self):
 65        return {
 66            "first_subject_name": self.first_subject.name,
 67            "second_subject_name": self.second_subject.name,
 68            "score": self.score,
 69            "relevant_aspects": self.relevant_aspects,
 70            "relevant_default_aspects": self.relevant_default_aspects,
 71            "is_destiny_sign": self.is_destiny_sign,
 72        }
 73
 74    def _log_aspect(self, aspect: dict, points: int) -> None:
 75        logging.debug(
 76            f"{points} Points: {aspect['p1_name']} {aspect['aspect']} {aspect['p2_name']}, rounded orbit: {int(aspect['orbit'])}"
 77        )
 78
 79    def _evaluate_destiny_sign(self) -> int:
 80        """
 81        5 points if is a destiny sign:
 82        """
 83        if self.first_subject.sun["quality"] == self.second_subject.sun["quality"]:
 84            logging.debug(
 85                f'5 points: Destiny sign, {self.first_subject.sun["sign"]} and {self.second_subject.sun["sign"]}'
 86            )
 87            self.is_destiny_sign = True
 88            return 5
 89
 90        return 0
 91
 92    def _check_if_sun_sun_aspect(self, aspect: dict, log: bool = True) -> int:
 93        """
 94        8 points if Sun conjunction/opposition/square to Sun,
 95        11 if diff <= 2 degrees:
 96        """
 97        aspect_types = ["conjunction", "opposition", "square"]
 98
 99        if (aspect["p1_name"] == "Sun" and aspect["p2_name"] == "Sun") and (aspect["aspect"] in aspect_types):
100            self.relevant_default_aspects.append(aspect)
101
102            if aspect["orbit"] <= 2:
103                score = 11
104
105                self._log_aspect(aspect, score)
106                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
107
108                return score
109            else:
110                score = 8
111
112                self._log_aspect(aspect, score)
113                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
114
115                return score
116
117        return 0
118
119    def _check_if_sun_moon_conjunction(self, aspect: dict) -> int:
120        """
121        8 points if Moon conjunction/opposition/square to Moon,
122        11 if diff <= 2 degrees:
123        """
124        planets = set(["Moon", "Sun"])
125
126        if set([aspect["p1_name"], aspect["p2_name"]]) == planets and aspect["aspect"] == "conjunction":
127            self.relevant_default_aspects.append(aspect)
128
129            if aspect["orbit"] <= 2:
130                score = 11
131
132                self._log_aspect(aspect, score)
133                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
134
135                return score
136
137            else:
138                score = 8
139
140                self._log_aspect(aspect, score)
141                self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
142
143                return score
144
145        return 0
146
147    def _check_if_sun_moon_asc_aspect(self, aspect: dict) -> int:
148        planets = ["Sun", "Moon", "First_House"]
149
150        if self._check_if_sun_sun_aspect(aspect) or self._check_if_sun_moon_conjunction(aspect):
151            return 0
152
153        if aspect["p1_name"] in planets and aspect["p2_name"] in planets:
154            self.relevant_default_aspects.append(aspect)
155            score = 4
156
157            self._log_aspect(aspect, score)
158            self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
159
160            return score
161
162        return 0
163
164    def _check_if_venus_mars_aspect(self, aspect: dict) -> int:
165        planets = set(["Venus", "Mars"])
166        if set([aspect["p1_name"], aspect["p2_name"]]) == planets:
167            score = 4
168            self.relevant_default_aspects.append(aspect)
169
170            self._log_aspect(aspect, score)
171            self.relevant_aspects.append(self._create_aspects_dictionary(aspect, score))
172
173            return score
174
175        return 0
176
177    def _create_aspects_dictionary(self, aspect: dict, score: int) -> dict:
178        return {
179            "points": score,
180            "p1_name": aspect["p1_name"],
181            "p2_name": aspect["p2_name"],
182            "aspect": aspect["aspect"],
183            "orbit": aspect["orbit"],
184        }
185
186    def _get_all(self) -> None:
187        self.score += self._evaluate_destiny_sign()
188
189        for a in self.__all_synastry_aspects:
190            self.score += self._check_if_sun_sun_aspect(a)
191            self.score += self._check_if_sun_moon_conjunction(a)
192            self.score += self._check_if_sun_moon_asc_aspect(a)
193            self.score += self._check_if_venus_mars_aspect(a)

Calculates the relevance of the relationship of the two subjects according to Ciro Discepolo method.

Results: - From 0 to 5 = Null relationship - From 5 a 10 = Mediocre relationship - From 10 to 15 = Important relationship - From 15 to 20 = Very important relationship - From 20 to su = Exceptional relationship

Documentation at: http://www.cirodiscepolo.it/Articoli/Discepoloele.htm

Args: first_subject (AstrologicalSubject): First subject kerykeion instance second_subject (AstrologicalSubject): Second subject kerykeion instance

RelationshipScore( first_subject: kerykeion.astrological_subject.AstrologicalSubject, second_subject: kerykeion.astrological_subject.AstrologicalSubject, new_settings_file: Optional[pathlib.Path] = None)
42    def __init__(
43        self,
44        first_subject: AstrologicalSubject,
45        second_subject: AstrologicalSubject,
46        new_settings_file: Union[Path, None] = None,
47    ):
48        self.first_subject = first_subject
49        self.second_subject = second_subject
50        self.score = 0
51        self.is_destiny_sign = False
52        self.relevant_aspects = []
53        self.relevant_default_aspects = []
54        self.__all_synastry_aspects = SynastryAspects(
55            first_subject, second_subject, new_settings_file=new_settings_file
56        ).all_aspects
57
58        # Calculates all at initialization
59        self._get_all()
score: int
is_destiny_sign: bool
relevant_aspects: list
relevant_default_aspects: list