Commit c4413c07 authored by dirk.wintergruen's avatar dirk.wintergruen
Browse files

added parameter fill empty

parent f09b0b11
......@@ -1427,6 +1427,7 @@ def calcTop(
displayAttr2=None,
deleteZero=True,
normalize=None,
fill_empty = False,
**kwargs
):
"""
......@@ -1443,6 +1444,7 @@ def calcTop(
:param displayAttr2: Additional attribute, defaults to None
:param deleteZero: Don't return entries with value 0, defaults to True
:param normalize: Normalize the results, value can be None, mean or median, defaults to None
:param fill_empty: extend all entries to the length number, defaults to false
:param kwargs: kwargs to be passed to the centrality to function see above
:return:
"""
......@@ -1520,7 +1522,10 @@ def calcTop(
bct_pairs_sorted = sorted(bct_pairs, key=lambda x: x[-1])
bct_pairs_sorted.reverse()
return bct_pairs_sorted[0:number]
ret = bct_pairs_sorted[0:number]
if len(ret) < number and fill_empty:
ret = ret + [("", math.nan) for x in range(0, number - len(ret))]
return ret
def calcTopsForYears(
......@@ -1534,6 +1539,7 @@ def calcTopsForYears(
displayAttr2=None,
deleteZero=True,
normalize=None,
fill_empty = False,
mode ="vertex",
**kwargs
):
......@@ -1550,6 +1556,7 @@ def calcTopsForYears(
:param displayAttr2: Additional attribute, defaults to None
:param deleteZero: Don't return entries with value 0, defaults to True
:param normalize: Normalize the results, value can be None, mean or median, defaults to None
:param fill_empty: extend all entries to the length number, defaults to false
:param kwargs: kwargs to be passed to the centrality to function see above
:return:
......@@ -1593,6 +1600,7 @@ def calcTopsForYears(
deleteZero=deleteZero,
normalize=normalize,
mode=mode,
fill_empty = fill_empty,
**kwargs
)
......@@ -1608,6 +1616,7 @@ def calcTopsForYears(
deleteZero=deleteZero,
normalize=normalize,
mode = mode,
fill_empty = fill_empty,
**kwargs
)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment