* src/plugins/CountAncestors.py: Add percent of theoretical ancestors
svn: r6496
This commit is contained in:
parent
1c5bd0e1b3
commit
c872bd6051
@ -1,3 +1,6 @@
|
|||||||
|
2006-04-29 Brian Matherly <brian@gramps-project.org>
|
||||||
|
* src/plugins/CountAncestors.py: Add percent of theoretical ancestors
|
||||||
|
|
||||||
2006-04-28 Don Allingham <don@gramps-project.org>
|
2006-04-28 Don Allingham <don@gramps-project.org>
|
||||||
* src/AddMedia.py: assign handle to notes
|
* src/AddMedia.py: assign handle to notes
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
import os
|
import os
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from sets import Set
|
from sets import Set
|
||||||
|
from math import pow
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -65,6 +66,7 @@ class CountAncestors:
|
|||||||
thisgen = Set()
|
thisgen = Set()
|
||||||
all = Set()
|
all = Set()
|
||||||
allgen = 0
|
allgen = 0
|
||||||
|
total_theoretical = 0
|
||||||
thisgen.add(person.get_handle())
|
thisgen.add(person.get_handle())
|
||||||
|
|
||||||
title = _("Number of ancestors of \"%s\" by generation") % person.get_primary_name().get_name()
|
title = _("Number of ancestors of \"%s\" by generation") % person.get_primary_name().get_name()
|
||||||
@ -76,10 +78,13 @@ class CountAncestors:
|
|||||||
if thisgen:
|
if thisgen:
|
||||||
thisgensize = len( thisgen )
|
thisgensize = len( thisgen )
|
||||||
gen -= 1
|
gen -= 1
|
||||||
|
theoretical = pow(2, ( gen * -1 ) )
|
||||||
|
total_theoretical += theoretical
|
||||||
|
percent = ( thisgensize / theoretical ) * 100
|
||||||
if thisgensize == 1 :
|
if thisgensize == 1 :
|
||||||
text += _("Generation %d has 1 individual.\n") % (gen)
|
text += _("Generation %d has 1 individual. (%3.2f%%)\n") % (gen,percent)
|
||||||
else:
|
else:
|
||||||
text += _("Generation %d has %d individuals.\n") % (gen, thisgensize)
|
text += _("Generation %d has %d individuals. (%3.2f%%)\n") % (gen,thisgensize,percent)
|
||||||
temp = thisgen
|
temp = thisgen
|
||||||
thisgen = Set()
|
thisgen = Set()
|
||||||
for person_handle in temp:
|
for person_handle in temp:
|
||||||
@ -97,7 +102,12 @@ class CountAncestors:
|
|||||||
all.add(mother_handle)
|
all.add(mother_handle)
|
||||||
allgen += len(thisgen)
|
allgen += len(thisgen)
|
||||||
|
|
||||||
text += _("Total ancestors in generations %d to -1 is %d.\n") % (gen, allgen)
|
if( total_theoretical != 1 ):
|
||||||
|
percent = ( (allgen) / (total_theoretical-1) ) * 100
|
||||||
|
else:
|
||||||
|
percent = 0
|
||||||
|
|
||||||
|
text += _("Total ancestors in generations %d to -1 is %d. (%3.2f%%)\n") % (gen,allgen,percent)
|
||||||
|
|
||||||
top = topDialog.get_widget("summary")
|
top = topDialog.get_widget("summary")
|
||||||
textwindow = topDialog.get_widget("textwindow")
|
textwindow = topDialog.get_widget("textwindow")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user