Example #1
0
    def test_US18_Siblings_should_not_marry(self):
        t1 = Family("t1")
        t2 = Family("t2")
        t3 = Family("t3")
        t4 = Family("t4")
        t5 = Family("t5")
        t6 = Family("t6")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        # --------------------------------------------------

        t1.set_husband(p1)
        t1.set_wife(p2)
        t4.set_husband(p3)
        t4.set_wife(p4)
        '''
        t2.add_child(p1)
        t3.add_child(p2)
        t4.set_husband(p3)
        t4.set_wife(p4)
        t5.add_child(p3)
        t5.add_child(p4)
        '''
        # --------------------------------------------------
        p1.set_parentFamily(t2)
        p2.set_parentFamily(t3)
        p3.set_parentFamily(t5)
        p4.set_parentFamily(t5)
        # --------------------------------------------------
        assert t1.siblings_should_not_marry() == True
        #assert t2.siblings_should_not_marry() == True
        assert t4.siblings_should_not_marry() == False
Example #2
0
    def tearDown(self):
        self.ind_1 = Individual("01")
        self.ind_2 = Individual("02")
        self.ind_3 = Individual("03")

        self.fam_1 = Family("01")
        self.fam_2 = Family("02")
 def test1(self):
     male1 = Individual("P01")
     female1 = Individual("P02")
     family1 = Family("F01")
     male1.set_deathDate(["5", "MAR", "2000"])
     female1.set_deathDate(["9", "APR", "2002"])
     family1.set_husband(male1)
     family1.set_wife(female1)
     family1.set_divorced(["1", "JAN", "1999"])
     self.assertTrue(family1.divorce_before_death())
Example #4
0
 def test_US17_No_marriages_to_descendants(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     p1 = Individual("p1")
     p2 = Individual("p2")
     p3 = Individual("p3")
     p4 = Individual("p4")
     p5 = Individual("p5")
     p6 = Individual("p6")
     p7 = Individual("p7")
     p8 = Individual("p8")
     p9 = Individual("p9")
     t1.set_husband(p1)
     t1.set_wife(p2)
     t1.add_child(p3)
     t2.set_wife(p3)
     t2.set_husband(p4)
     t2.add_child(p5)
     t3.set_husband(p6)
     t3.set_wife(p7)
     t3.add_child(p8)
     t4.set_husband(p6)
     t4.set_wife(p8)
     t4.add_child(p9)
Example #5
0
 def test_US08_birth_before_marriage_of_parents(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     child1 = Individual("P03")
     t1.add_child(child1)
     t1.set_marriedDate(['8', 'SEP', '2000'])
     child1.set_birthDate(["6", "JAN", "1998"])
     t1.set_husband(male1)
     t1.set_wife(female1)
     # ---------------------------------
     t2 = Family("F02")
     male2 = Individual("P04")
     female2 = Individual("P05")
     child2 = Individual("P06")
     t2.add_child(child2)
     t2.set_marriedDate(['8', 'SEP', '2000'])
     child2.set_birthDate(["6", "JAN", "2001"])
     t2.set_husband(male2)
     t2.set_wife(female2)
     # ---------------------------------
     t3 = Family("F03")
     male3 = Individual("P07")
     female3 = Individual("P08")
     child3 = Individual("P09")
     t3.add_child(child3)
     t3.set_marriedDate(['6', 'MAR', '2000'])
     child3.set_birthDate(["6", "MAR", "2000"])
     t3.set_husband(male3)
     t3.set_wife(female3)
     # ---------------------------------
     assert t1.birth_before_marriage_of_parents() == False
     assert t2.birth_before_marriage_of_parents() == True
     assert t3.birth_before_marriage_of_parents() == False
 def test3(self):
     male1 = Individual("P01")
     female1 = Individual("P02")
     child1 = Individual("P03")
     family1 = Family("F01")
     family1.add_child(child1)
     male1.set_deathDate(["5", "MAR", "2000"])
     female1.set_deathDate(["9", "APR", "2002"])
     child1.set_birthDate(["6", "MAR", "2000"])
     family1.set_husband(male1)
     family1.set_wife(female1)
     self.assertTrue(family1.birth_before_death_of_parents())
Example #7
0
 def test_US10_marriage_after_14(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     male1.set_birthDate(['8', 'SEP', '2000'])
     female1.set_birthDate(['8', 'SEP', '2000'])
     t1.set_husband(male1)
     t1.set_wife(female1)
     t1.set_marriedDate(['8', 'SEP', '2014'])
     # --------------------------------------------------
     t2 = Family("F02")
     male2 = Individual("P03")
     female2 = Individual("P04")
     male2.set_birthDate(['7', 'SEP', '2000'])
     female2.set_birthDate(['8', 'SEP', '2000'])
     t2.set_husband(male2)
     t2.set_wife(female2)
     t2.set_marriedDate(['8', 'SEP', '2014'])
     # --------------------------------------------------
     t3 = Family("F03")
     male3 = Individual("P05")
     female3 = Individual("P06")
     male3.set_birthDate(['8', 'SEP', '2000'])
     female3.set_birthDate(['7', 'SEP', '2000'])
     t3.set_husband(male3)
     t3.set_wife(female3)
     t3.set_marriedDate(['8', 'SEP', '2014'])
     # --------------------------------------------------
     t4 = Family("F04")
     male4 = Individual("P07")
     female4 = Individual("P08")
     male4.set_birthDate(['1', 'SEP', '1990'])
     female4.set_birthDate(['2', 'SEP', '1990'])
     t4.set_husband(male4)
     t4.set_wife(female4)
     t4.set_marriedDate(['8', 'SEP', '2014'])
     # --------------------------------------------------
     t5 = Family("F05")
     male5 = Individual("P09")
     female5 = Individual("P10")
     male5.set_birthDate(['09', 'APR', '1997'])
     female5.set_birthDate(['19', 'DEC', '1997'])
     t5.set_husband(male5)
     t5.set_wife(female5)
     t5.set_marriedDate(['1', 'JUN', '2007'])
     # --------------------------------------------------
     assert t1.marriage_after_14() == False
     assert t2.marriage_after_14() == False
     assert t3.marriage_after_14() == False
     assert t4.marriage_after_14() == True
     assert t5.marriage_after_14() == False
Example #8
0
 def test_US05_marriage_before_death(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     male1.set_deathDate(['8', 'SEP', '2010'])
     female1.set_deathDate(['8', 'SEP', '2011'])
     t1.set_husband(male1)
     t1.set_wife(female1)
     t1.set_marriedDate(['8', 'SEP', '2000'])
     # ---------------------------------
     t2 = Family("F02")
     male2 = Individual("P03")
     female2 = Individual("P04")
     male2.set_deathDate(['8', 'SEP', '1999'])
     female2.set_deathDate(['9', 'SEP', '2011'])
     t2.set_husband(male2)
     t2.set_wife(female2)
     t2.set_marriedDate(['8', 'SEP', '2000'])
     # ---------------------------------
     t3 = Family("F03")
     male3 = Individual("P05")
     female3 = Individual("P06")
     male3.set_deathDate(['8', 'SEP', '2003'])
     female3.set_deathDate(['9', 'SEP', '1998'])
     t3.set_husband(male3)
     t3.set_wife(female3)
     t3.set_marriedDate(['8', 'SEP', '2000'])
     # ---------------------------------
     t4 = Family("F04")
     male4 = Individual("P07")
     female4 = Individual("P08")
     male4.set_deathDate(['8', 'SEP', '1998'])
     female4.set_deathDate(['9', 'SEP', '1999'])
     t4.set_husband(male4)
     t4.set_wife(female4)
     t4.set_marriedDate(['8', 'SEP', '2000'])
     # ---------------------------------
     t5 = Family("F05")
     male5 = Individual("P09")
     female5 = Individual("P10")
     male5.set_deathDate(['8', 'SEP', '2009'])
     female5.set_deathDate(['8', 'SEP', '2009'])
     t5.set_husband(male5)
     t5.set_wife(female5)
     t5.set_marriedDate(['8', 'SEP', '2009'])
     # ---------------------------------
     assert t1.marriage_before_death() == True
     assert t2.marriage_before_death() == False
     assert t3.marriage_before_death() == False
     assert t4.marriage_before_death() == False
     assert t5.marriage_before_death() == True
Example #9
0
 def test_US28_Order_siblings_by_age(self):
     t1 = Family("t1")
     t2 = Family("t2")
     p1 = Individual("p1")
     p1.set_birthDate((1990, 4, 1))
     p2 = Individual("p2")
     p2.set_birthDate((1990, 1, 1))
     p3 = Individual("p3")
     p3.set_birthDate((1990, 9, 1))
     p4 = Individual("p4")
     p4.set_birthDate((1987, 1, 1))
     p5 = Individual("p5")
     p5.set_birthDate((2019, 1, 1))
     p6 = Individual("p6")
     p6.set_birthDate((2017, 5, 30))
     p7 = Individual("p7")
     p7.set_birthDate((2018, 3, 30))
     p8 = Individual("p8")
     p8.set_birthDate((2019, 8, 30))
     # --------------------------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t1.add_child(p3)
     t1.add_child(p4)
     t1.add_child(p5)
     t1.add_child(p6)
     t2.add_child(p1)
     t2.add_child(p2)
     t2.add_child(p3)
     t2.add_child(p4)
     t2.add_child(p7)
     t2.add_child(p8)
     # --------------------------------------------------
     assert t1.order_siblings_by_age() == [p4, p2, p1, p3, p6, p5]
     assert t2.order_siblings_by_age() == [p4, p2, p1, p3, p7, p8]
Example #10
0
    def setUp(self):
        SUPPORT_TAGS = {
            "INDI", "NAME", "SEX", "BIRT", "DEAT", "FAMC", "FAMS", "FAM",
            "MARR", "HUSB", "WIFE", "CHIL", "DIV", "DATE", "HEAD", "TRLR",
            "NOTE"
        }
        # self.G1 = Gedcom('../testing_files/right.ged', SUPPORT_TAGS)
        # self.G2 = Gedcom('../testing_files/wrong.ged', SUPPORT_TAGS)

        self.ind_1 = Individual("01")
        self.ind_2 = Individual("02")
        self.ind_3 = Individual("03")

        self.fam_1 = Family("01")
        self.fam_2 = Family("02")
Example #11
0
 def mutate(self, individual: Individual) -> Individual:
     length = len(individual.nodes)
     first_index = randrange(start=0, stop=length)
     second_index = randrange(start=first_index, stop=length)
     mutated_nodes = individual.nodes[:first_index] + individual.nodes[
         first_index:second_index][::-1] + individual.nodes[second_index:]
     return Individual(mutated_nodes)
Example #12
0
 def mutate(self, individual: Individual) -> Individual:
     length = len(individual.nodes)
     first_index = randrange(start=0, stop=length)
     second_index = randrange(start=0, stop=length)
     mutated_nodes = individual.nodes[:]
     mutated_nodes[first_index], mutated_nodes[
         second_index] = mutated_nodes[second_index], mutated_nodes[
             first_index]
     return Individual(mutated_nodes)
Example #13
0
    def test_date_compare(self):
        fam_1 = Family("01")
        ind_1 = Individual("01")
        ind_1.set_birthDate((2019, 9, 1))
        ind_1.set_parentFamily(fam_1)
        fam_1.set_marriedDate((2019, 9, 2))
        ind_1.set_deathDate((2020, 9, 1))

        fam_2 = Family("02")
        ind_2 = Individual("02")
        ind_2.set_birthDate((2019, 8, 1))
        ind_2.set_parentFamily((fam_2))
        fam_2.set_marriedDate((2019, 7, 1))
        ind_2.set_deathDate((2018, 8, 1))
        assert ind_1.birth_before_marriage() == True
        assert ind_2.birth_before_marriage() == False

        assert ind_1.birth_before_death() == True
        assert ind_2.birth_before_death() == False
Example #14
0
 def crossover(self, first_individual: Individual, second_individual: Individual) -> Individual:
     length = len(first_individual.nodes)
     first_index = randrange(start=0, stop=length)
     second_index = randrange(start=first_index, stop=length)
     subnodes = first_individual.nodes[first_index:second_index]
     nodes = second_individual.nodes[:]
     for node in subnodes:
         nodes.remove(node)
     pasting_index = randrange(start=0, stop=length)
     return Individual(nodes[:pasting_index] + subnodes + nodes[pasting_index:])
Example #15
0
    def test_US21_Correct_Gender_For_Role(self):
        t1 = Family("t1")
        t2 = Family("t2")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")

        # ---------------------------------
        t1.set_wife(p1)
        t1.set_husband(p2)
        t2.set_wife(p3)
        t2.set_husband(p4)
        p1.set_gender('F')
        p2.set_gender('M')
        p4.set_gender('F')
        p3.set_gender('M')
        # ---------------------------------
        assert t1.correct_gender_for_role() == True
        assert t2.correct_gender_for_role() == False
Example #16
0
    def test_US12_parents_not_too_old(self):
        t1 = Family("t1")
        t2 = Family("t2")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        t1.set_wife(p1)
        t1.set_husband(p2)
        t1.add_child(p3)
        t2.set_wife(p4)
        t2.set_husband(p5)
        t2.add_child(p6)
        p1.set_birthDate(["1", "JAN", "1990"])
        p2.set_birthDate(["1", "JAN", "1990"])
        p4.set_birthDate(["1", "JAN", "1790"])
        p5.set_birthDate(["1", "JAN", "1790"])

        p3.set_birthDate(["1", "JAN", "2010"])
        p6.set_birthDate(["1", "JAN", "2000"])
        # ---------------------------------
        assert t1.parents_not_too_old() == True
        assert t2.parents_not_too_old() == False
Example #17
0
    def test_US06_divorse_before_death(self):
        t1 = Family("F01")
        male1 = Individual("P01")
        female1 = Individual("P02")
        male1.set_deathDate(["5", "MAR", "2000"])
        female1.set_deathDate(["9", "APR", "2002"])
        t1.set_husband(male1)
        t1.set_wife(female1)
        t1.set_divorcedDate(["1", "JAN", "1999"])
        # ---------------------------------
        t2 = Family("F02")
        male2 = Individual("P03")
        female2 = Individual("P04")
        male2.set_deathDate(["5", "MAR", "2000"])
        female2.set_deathDate(["9", "APR", "2002"])
        t2.set_husband(male2)
        t2.set_wife(female2)
        t2.set_divorcedDate(["1", "JAN", "2003"])

        # ---------------------------------
        assert t1.divorce_before_death() == True
        assert t2.divorce_before_death() == False
Example #18
0
    def test_US19_First_cousins_should_not_marry(self):
        t1 = Family("t1")
        t2 = Family("t2")
        t3 = Family("t3")
        t4 = Family("t4")
        t5 = Family("t5")
        t6 = Family("t6")
        t7 = Family("t7")
        t8 = Family("t8")
        t9 = Family("t9")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        p7 = Individual("p7")
        p8 = Individual("p8")
        # --------------------------------------------------
        '''
        t1.add_child(p1)
        t1.add_child(p2)
        t2.set_wife(p1)
        t2.add_child(p3)
        t3.set_wife(p2)
        t3.add_child(p4)
        t4.set_husband(p3)
        t5.set_wife(p4)
        
        t6.add_child(p5)
        t6.add_child(p6)
        t7.set_wife(p5)
        t8.set_wife(p6)
        t7.add_child(p7)
        t8.add_child(p8)
        t9.set_wife(p7)
        t9.set_husband(p8)
        '''
        # --------------------------------------------------
        p3.set_parentFamily(t1)
        t1.set_husband(p8)
        t1.set_wife(p7)
        p8.set_parentFamily(t2)
        p7.set_parentFamily(t3)
        t2.add_child(p8)
        t3.add_child(p7)

        assert p3.first_cousins_should_not_marry() == True
Example #19
0
 def test_US04_marriage_before_divorce(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     male1.set_deathDate(['8', 'SEP', '2010'])
     female1.set_deathDate(['8', 'SEP', '2011'])
     t1.set_husband(male1)
     t1.set_wife(female1)
     t1.set_marriedDate(['8', 'SEP', '2000'])
     t1.set_divorcedDate(['8', 'SEP', '2009'])
     # ---------------------------------
     t2 = Family("F02")
     male2 = Individual("P03")
     female2 = Individual("P04")
     male2.set_deathDate(['8', 'SEP', '2012'])
     female2.set_deathDate(['8', 'SEP', '2013'])
     t2.set_husband(male2)
     t2.set_wife(female2)
     t2.set_marriedDate(['8', 'SEP', '2005'])
     t2.set_divorcedDate(['8', 'SEP', '2004'])
     # ---------------------------------
     assert t1.marriage_before_divorce() == True
     assert t2.marriage_before_divorce() == False
Example #20
0
 def test_US09_birth_before_death_of_parent(self):
     t1 = Family("F01")
     male1 = Individual("P01")
     female1 = Individual("P02")
     child1 = Individual("P03")
     t1.add_child(child1)
     male1.set_deathDate(["5", "MAR", "2000"])
     female1.set_deathDate(["9", "APR", "2002"])
     child1.set_birthDate(["6", "JAN", "1998"])
     t1.set_husband(male1)
     t1.set_wife(female1)
     # ---------------------------------
     t2 = Family("F02")
     male2 = Individual("P04")
     female2 = Individual("P05")
     child2 = Individual("P06")
     t2.add_child(child2)
     male2.set_deathDate(["5", "MAR", "2000"])
     female2.set_deathDate(["9", "APR", "2002"])
     child2.set_birthDate(["6", "JAN", "2001"])
     t2.set_husband(male2)
     t2.set_wife(female2)
     # ---------------------------------
     t3 = Family("F03")
     male3 = Individual("P07")
     female3 = Individual("P08")
     child3 = Individual("P09")
     t3.add_child(child3)
     male3.set_deathDate(["5", "MAR", "2000"])
     female3.set_deathDate(["9", "APR", "2002"])
     child3.set_birthDate(["6", "MAR", "2000"])
     t3.set_husband(male3)
     t3.set_wife(female3)
     # ---------------------------------
     assert t1.birth_before_death_of_parents() == True
     assert t2.birth_before_death_of_parents() == False
     assert t3.birth_before_death_of_parents() == True
Example #21
0
 def test_siblings_spacing(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     t5 = Family("t5")
     t6 = Family("t6")
     p1 = Individual("p1")
     p1.set_birthDate((1990, 1, 1))
     p2 = Individual("p2")
     p2.set_birthDate((1990, 1, 1))
     p3 = Individual("p3")
     p3.set_birthDate((1990, 9, 1))
     p4 = Individual("p4")
     p4.set_birthDate((1990, 1, 2))
     p5 = Individual("p5")
     p5.set_birthDate((1990, 1, 3))
     p6 = Individual("p6")
     p6.set_birthDate((1990, 5, 30))
     # --------------------------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t2.add_child(p1)
     t2.add_child(p3)
     t3.add_child(p1)
     t3.add_child(p4)
     t4.add_child(p1)
     t4.add_child(p5)
     t5.add_child(p1)
     t5.add_child(p6)
     t6.add_child(p1)
     t6.add_child(p3)
     t6.add_child(p6)
     # --------------------------------------------------
     assert t1.siblings_spacing() == True
     assert t2.siblings_spacing() == True
     assert t3.siblings_spacing() == True
     assert t4.siblings_spacing() == False
     assert t5.siblings_spacing() == False
     assert t6.siblings_spacing() == False
Example #22
0
 def test_US13_siblings_spacing(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     t5 = Family("t5")
     t6 = Family("t6")
     p1 = Individual("p1")
     p1.set_birthDate(("1", "JAN", "1990"))
     p2 = Individual("p2")
     p2.set_birthDate(("1", "JAN", "1990"))
     p3 = Individual("p3")
     p3.set_birthDate(("1", "SEP", "1990"))
     p4 = Individual("p4")
     p4.set_birthDate(("2", "JAN", "1990"))
     p5 = Individual("p5")
     p5.set_birthDate(("3", "JAN", "1990"))
     p6 = Individual("p6")
     p6.set_birthDate(("30", "MAY", "1990"))
     # --------------------------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t2.add_child(p1)
     t2.add_child(p3)
     t3.add_child(p1)
     t3.add_child(p4)
     t4.add_child(p1)
     t4.add_child(p5)
     t5.add_child(p1)
     t5.add_child(p6)
     t6.add_child(p1)
     t6.add_child(p3)
     t6.add_child(p6)
     # --------------------------------------------------
     assert t1.siblings_spacing() == True
     assert t2.siblings_spacing() == True
     assert t3.siblings_spacing() == True
     assert t4.siblings_spacing() == False
     assert t5.siblings_spacing() == False
     assert t6.siblings_spacing() == False
Example #23
0
 def run_without_initial_node(self, nodes: List[Node]) -> Individual:
     internal_nodes = nodes[:]
     initial_node = choice(internal_nodes)
     internal_nodes.remove(initial_node)
     (nodes, distance) = self.__evaluate(initial_node, internal_nodes)
     return Individual(nodes, distance)
Example #24
0
 def parse(self):
     #from Individual import Individual
     #from Family import Family
     offset = 0
     for i in range(len(self._data[1]) - 1):  # enumerate individuals
         start_index = self._data[1][i]
         end_index = self._data[1][i + 1]
         # print(self._data[0][start_index:end_index])
         # TODO: check deplicated ids
         id = self._data[0][start_index][2]
         if id in self._individuals:
             offset += 1
             id = "@I" + str(int(id[2:-1]) + offset) + "@"
         new_indi = Individual(id)
         new_indi.set_lineNum(self._data[3][start_index])
         self._individuals[id] = new_indi
         # print(start_index, end_index)
         for j in range(start_index + 1, end_index):
             level, tag, arguments = self._data[0][j]
             if tag == "NAME":
                 new_indi.set_name("".join(arguments))
             elif tag == "SEX":
                 new_indi.set_gender(arguments[0])
             elif tag == "BIRT":  # set missing dates to Jan/01
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 try:
                     new_indi.set_birthDate(arguments)
                 except ValueError as e:
                     print(e)  # TODO:how to handle error?
             elif tag == "DEAT":
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 new_indi.set_deathDate(arguments)
             elif tag == "FAMS":
                 if arguments[0] not in self._families:
                     new_fam = Family(arguments[0])
                     self._families[arguments[0]] = new_fam
                 new_indi.add_to_family(self._families[arguments[0]])
             elif tag == "FAMC":
                 if arguments[0] not in self._families:
                     new_fam = Family(arguments[0])
                     self._families[arguments[0]] = new_fam
                 new_indi.set_parentFamily(self._families[arguments[0]])
     offset = 0
     for i in range(len(self._data[2]) - 1):
         start_index = self._data[2][i]
         end_index = self._data[2][i + 1]
         # print(self._data[0][start_index:end_index])
         id = self._data[0][start_index][2]
         # if id in self._families:  #TODO: handle duplicate
         #     offset+=1
         #     id = "@F" + str(int(id[2:-1]) + offset) + "@"
         new_fam = Family(id)
         new_fam.set_lineNum(self._data[3][start_index])
         self._families[id] = new_fam
         for j in range(start_index + 1, end_index):
             level, tag, arguments = self._data[0][j]
             # print(level, tag, arguments)
             if tag == "HUSB":
                 new_fam.set_husband(self._individuals[arguments[0]])
             elif tag == "WIFE":
                 new_fam.set_wife(self._individuals[arguments[0]])
             elif tag == "CHIL":
                 new_fam.add_child(self._individuals[arguments[0]])
             elif tag == "MARR":
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 # print(level, tag, arguments)
                 try:
                     new_fam.set_marriedDate(arguments)
                 except:
                     continue
             elif tag == "DIV":
                 j += 1
                 level, tag, arguments = self._data[0][j]
                 # print(level, tag, arguments)
                 try:
                     new_fam.set_divorcedDate(arguments)
                 except:
                     continue
Example #25
0
 def test_US20_Aunts_and_uncles(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     t4 = Family("t4")
     t5 = Family("t5")
     t6 = Family("t6")
     t7 = Family("t7")
     t8 = Family("t8")
     t9 = Family("t9")
     t10 = Family("t10")
     t11 = Family("t11")
     t12 = Family("t12")
     p1 = Individual("p1")
     p2 = Individual("p2")
     p3 = Individual("p3")
     p4 = Individual("p4")
     p5 = Individual("p5")
     p6 = Individual("p6")
     p7 = Individual("p7")
     p8 = Individual("p8")
     p9 = Individual("p9")
     p10 = Individual("p10")
     p11 = Individual("p11")
     # --------------------------------------------------
     p11.set_parentFamily(t1)
     t1.set_husband(p1)
     t1.set_wife(p2)
     p1.set_parentFamily(t2)
     p2.set_parentFamily(t3)
     #t2.set_husband(p3)
     #t2.set_wife(p4)
     #t3.set_husband(p5)
     #t3.set_wife(p6)
     t2.set_children([p1, p7, p8])
     t3.set_children([p2, p9, p10])
     '''
     t1.add_child(p3)
     t1.add_child(p4)
     t2.set_husband(p3)
     t3.set_wife(p4)
     t2.add_child(p5)
     t3.add_child(p6)
     t4.set_husband(p7)
     t4.set_wife(p8)
     t4.add_child(p9)
     t4.add_child(p10)
     t5.set_husband(p9)
     t5.add_child(p11)
     t6.set_husband(p10)
     t6.set_wife(p11)
     '''
     # --------------------------------------------------
     assert p11.aunts_and_uncles() == True
Example #26
0
    def test_US16_Male_last_names(self):
        t1 = Family("t1")
        t2 = Family("t2")
        t3 = Family("t3")
        t4 = Family("t4")
        t5 = Family("t5")
        t6 = Family("t6")
        t7 = Family("t7")
        t8 = Family("t8")
        t9 = Family("t9")
        t10 = Family("t10")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        p7 = Individual("p7")
        p8 = Individual("p8")
        p9 = Individual("p9")
        p10 = Individual("p10")
        # --------------------------------------------------
        t1.set_husband(p1)
        t1.add_child(p2)
        t1.add_child(p3)
        t2.set_husband(p2)
        t3.set_husband(p3)
        t2.add_child(p4)
        t3.add_child(p5)
        t4.set_husband(p4)
        t5.set_husband(p5)

        t6.set_husband(p6)
        t6.add_child(p7)
        t6.add_child(p8)
        t7.set_husband(p7)
        t8.set_husband(p8)
        t7.add_child(p9)
        t8.add_child(p10)
        t9.set_husband(p9)
        t10.set_husband(p10)

        p1.set_gender("M")
        p1.set_name("Charles Glass")
        p2.set_gender("M")
        p2.set_name("Charles Glass")
        p3.set_gender("M")
        p3.set_name("Charles Glass")
        p4.set_gender("M")
        p4.set_name("Charles Glass")
        p5.set_gender("M")
        p5.set_name("Charles Glass")

        p6.set_gender("M")
        p6.set_name("Charles Glass")
        p7.set_gender("M")
        p7.set_name("Charles Glass")
        p8.set_gender("M")
        p8.set_name("Charles WDNMD")
        p9.set_gender("M")
        p9.set_name("Charles Glass")
        p10.set_gender("M")
        p10.set_name("Charles Glass")

        # --------------------------------------------------

        assert t3.male_last_names() == True
        assert t8.male_last_names() == False
Example #27
0
 def test_US14_multiple_births_lessOrEqual_than_5(self):
     t1 = Family("t1")
     t2 = Family("t2")
     t3 = Family("t3")
     p1 = Individual("p1")
     p1.set_birthDate(("1", "JAN", "1990"))
     p2 = Individual("p2")
     p2.set_birthDate(("1", "JAN", "1990"))
     p3 = Individual("p3")
     p3.set_birthDate(("1", "JAN", "1990"))
     p4 = Individual("p4")
     p4.set_birthDate(("3", "JAN", "1990"))
     p5 = Individual("p5")
     p5.set_birthDate(("2", "JAN", "1990"))
     p6 = Individual("p6")
     p6.set_birthDate(("30", "MAY", "1990"))
     p7 = Individual("p7")
     p7.set_birthDate(("2", "JAN", "1990"))
     p8 = Individual("p8")
     p8.set_birthDate(("2", "JAN", "1990"))
     p9 = Individual("p9")
     p9.set_birthDate(("2", "SEP", "1990"))
     p10 = Individual("p10")
     p10.set_birthDate(("2", "SEP", "1990"))
     p11 = Individual("p11")
     p11.set_birthDate(("3", "SEP", "1990"))
     p12 = Individual("p12")
     p12.set_birthDate(("3", "SEP", "1990"))
     p13 = Individual("p13")
     p13.set_birthDate(("3", "SEP", "1990"))
     # -------------------------------
     t1.add_child(p1)
     t1.add_child(p2)
     t1.add_child(p3)
     t1.add_child(p4)
     t1.add_child(p5)
     t1.add_child(p6)
     t1.add_child(p7)
     t1.add_child(p8)
     t2.add_child(p1)
     t2.add_child(p2)
     t2.add_child(p3)
     t2.add_child(p4)
     t2.add_child(p5)
     t2.add_child(p6)
     t3.add_child(p3)
     t3.add_child(p4)
     t3.add_child(p5)
     t3.add_child(p6)
     t3.add_child(p7)
     t3.add_child(p8)
     t3.add_child(p9)
     t3.add_child(p10)
     t3.add_child(p11)
     t3.add_child(p12)
     t3.add_child(p13)
     # ---------------------------------
     assert t1.multiple_births_lessOrEqual_than_5() == False
     assert t2.multiple_births_lessOrEqual_than_5() == True
     assert t3.multiple_births_lessOrEqual_than_5() == False
Example #28
0
 def run(self, initial_node: Node, nodes: List[Node]) -> Individual:
     internal_nodes = nodes[:]
     (nodes, distance) = self.__evaluate(initial_node, internal_nodes)
     return Individual(nodes, distance)
def parse_valid_results(results):
    """
    Method to parse valid results from the GEDCOM file and return INDI/FAM dicts indexed by ID

    :param results -- List of valid GEDCOM results data formatted 'level, tag, valid, args'
    """
    families = {}
    individuals = {}
    current_fam_id = ""
    current_indi_id = ""
    duplicate_fam = []
    duplicate_ind = []
    results_iter = iter(results)
    for result in results_iter:
        if result[1] == 'FAM':
            if result[3] in families.keys():
                dup_fam_str = 'ERROR: FAMILY: US22: Family ID {} is a duplicate.'.format(
                    result[3])
                duplicate_fam.append(dup_fam_str)
            else:
                families[result[3]] = Family(result[3])
                current_fam_id = result[3]
        elif result[1] == 'INDI':
            if result[3] in individuals.keys():
                dup_ind_str = 'ERROR: INDIVIDUAL: US22: Individual ID {} is a duplicate.'.format(
                    result[3])
                duplicate_ind.append(dup_ind_str)
            else:
                individuals[result[3]] = Individual(result[3])
                current_indi_id = result[3]
        elif result[1] == 'NAME':
            individuals.get(current_indi_id).name = result[3]
        elif result[1] == 'SEX':
            individuals.get(current_indi_id).gender = result[3]
        elif result[1] == 'BIRT':
            indi = individuals.get(current_indi_id)
            date = next(results_iter)
            indi.birthday = date[3]
            indi.validate_birthday()
            indi.set_age()
        elif result[1] == 'DEAT':
            indi = individuals.get(current_indi_id)
            date = next(results_iter)
            indi.death = date[3]
            indi.alive = False
            indi.set_age()
        elif result[1] == 'FAMC':
            individuals.get(current_indi_id).child[result[3]] = result[3]
        elif result[1] == 'FAMS':
            individuals.get(current_indi_id).spouse[result[3]] = result[3]
        elif result[1] == 'HUSB':
            families.get(current_fam_id).husband_id = result[3]
        elif result[1] == 'WIFE':
            families.get(current_fam_id).wife_id = result[3]
        elif result[1] == 'CHIL':
            families.get(current_fam_id).children[result[3]] = result[3]
        elif result[1] == 'MARR':
            fam = families.get(current_fam_id)
            date = next(results_iter)
            fam.married = date[3]
        elif result[1] == 'DIV':
            fam = families.get(current_fam_id)
            date = next(results_iter)
            fam.divorced = date[3]
    return families, individuals, duplicate_fam, duplicate_ind
Example #30
0
    def test_US15_Fewer_than_15_siblings(self):
        t1 = Family("t1")
        t2 = Family("t2")
        p1 = Individual("p1")
        p2 = Individual("p2")
        p3 = Individual("p3")
        p4 = Individual("p4")
        p5 = Individual("p5")
        p6 = Individual("p6")
        p7 = Individual("p7")
        p8 = Individual("p8")
        p9 = Individual("p9")
        p10 = Individual("p10")
        p11 = Individual("p11")
        p12 = Individual("p12")
        p13 = Individual("p13")
        p14 = Individual("p14")
        p15 = Individual("p15")
        p16 = Individual("p16")
        p17 = Individual("p17")
        p18 = Individual("p18")
        p19 = Individual("p19")
        p20 = Individual("p20")
        p21 = Individual("p21")
        p22 = Individual("p22")
        p23 = Individual("p23")
        p24 = Individual("p24")
        p25 = Individual("p25")
        p26 = Individual("p26")
        p27 = Individual("p27")
        p28 = Individual("p28")

        # ---------------------------------
        t1.add_child(p1)
        t1.add_child(p2)
        t1.add_child(p3)
        t1.add_child(p4)
        t1.add_child(p5)
        t1.add_child(p6)
        t1.add_child(p7)
        t1.add_child(p8)
        t1.add_child(p9)
        t1.add_child(p10)
        t1.add_child(p11)
        t1.add_child(p12)
        t2.add_child(p13)
        t2.add_child(p14)
        t2.add_child(p15)
        t2.add_child(p16)
        t2.add_child(p17)
        t2.add_child(p18)
        t2.add_child(p19)
        t2.add_child(p20)
        t2.add_child(p21)
        t2.add_child(p22)
        t2.add_child(p23)
        t2.add_child(p24)
        t2.add_child(p25)
        t2.add_child(p26)
        t2.add_child(p27)
        t2.add_child(p28)
        # ---------------------------------
        assert t1.fewer_than_15_siblings() == True
        assert t2.fewer_than_15_siblings() == False