Esempio n. 1
0
 def test_draw_pedigree_hardcoded(self):
     '''Test drawing a pedigree as an EPS file using hard-coded positions.'''
     coord_params = fp.CoordParams()
     coord_params.algorithm = 'hardcoded'
     coord_params.coord_file = TestFamPlot.__PEDIGREE_POSITIONS
     coord_params.balance_marriages = False
     
     out = tempfile.NamedTemporaryFile(suffix='.eps', delete=False)
     ped_info = fp.draw_pedigree(TestFamPlot.__PEDIGREE, coord_params,
                                 fp.PlotParams(), fp.DEFAULT_COLORS, out)
     
     expected_coord = TestFamPlot.__read_coord_dict(coord_params.coord_file)
     test_util.assert_positions_almost_equal(ped_info.coord_dict, expected_coord,
                                             decimal=10, err_msg='Wrong coordinates')
 def test_layout_position(self):
     '''Test family computation.'''
     positions = pedigree_plot_laplacian._layout_positions(nx.path_graph(10, create_using=nx.DiGraph()))
     expected = {0: (-0.44170765403093781 , 9), 
                 1: (-0.39847023129619913 , 8), 
                 2: (-0.31622776601683716 , 7), 
                 3: (-0.20303072371134445 , 6), 
                 4: (-0.069959619570752599, 5), 
                 5: ( 0.069959619570755624, 4), 
                 6: ( 0.20303072371134645 , 3), 
                 7: ( 0.3162277660168385  , 2), 
                 8: ( 0.39847023129620007 , 1), 
                 9: ( 0.44170765403093859 , 0)}
     test_util.assert_positions_almost_equal(positions, expected, decimal=10, 
                                             err_msg='Wrong positions', allow_flip=True)
Esempio n. 3
0
    def test_draw_pedigree_hardcoded(self):
        '''Test drawing a pedigree as an EPS file using hard-coded positions.'''
        coord_params = fp.CoordParams()
        coord_params.algorithm = 'hardcoded'
        coord_params.coord_file = TestFamPlot.__PEDIGREE_POSITIONS
        coord_params.balance_marriages = False

        out = tempfile.NamedTemporaryFile(suffix='.eps', delete=False)
        ped_info = fp.draw_pedigree(TestFamPlot.__PEDIGREE, coord_params,
                                    fp.PlotParams(), fp.DEFAULT_COLORS, out)

        expected_coord = TestFamPlot.__read_coord_dict(coord_params.coord_file)
        test_util.assert_positions_almost_equal(ped_info.coord_dict,
                                                expected_coord,
                                                decimal=10,
                                                err_msg='Wrong coordinates')
Esempio n. 4
0
 def test_layout_position(self):
     '''Test family computation.'''
     positions = pedigree_plot_laplacian._layout_positions(
         nx.path_graph(10, create_using=nx.DiGraph()))
     expected = {
         0: (-0.44170765403093781, 9),
         1: (-0.39847023129619913, 8),
         2: (-0.31622776601683716, 7),
         3: (-0.20303072371134445, 6),
         4: (-0.069959619570752599, 5),
         5: (0.069959619570755624, 4),
         6: (0.20303072371134645, 3),
         7: (0.3162277660168385, 2),
         8: (0.39847023129620007, 1),
         9: (0.44170765403093859, 0)
     }
     test_util.assert_positions_almost_equal(positions,
                                             expected,
                                             decimal=10,
                                             err_msg='Wrong positions',
                                             allow_flip=True)