Skip to content
Snippets Groups Projects
Commit 433991f2 authored by Yassin's avatar Yassin
Browse files

Refactorings Code and Adding Node Filter

parent 8cd60a76
No related branches found
No related tags found
1 merge request!1Adding new methods and the consensual backbone
......@@ -24,7 +24,8 @@ def threshold_filter(backbone, value, narrate=True, secondary_property='weight',
ascending = backbone.ascending
if threshold_filter in backbone.compatible_filters():
data = data.sort_values(by=[property_name, secondary_property], ascending=[ascending, secondary_property_ascending])
data = data.sort_values(by=[property_name, secondary_property],
ascending=[ascending, secondary_property_ascending])
if narrate:
backbone.narrate()
......@@ -41,17 +42,17 @@ def threshold_filter(backbone, value, narrate=True, secondary_property='weight',
def fraction_filter(backbone, value, narrate=True, secondary_property='weight', secondary_property_ascending=False,
**kwargs):
data = backbone.to_dataframe()
column = backbone.property_name
ascending = backbone.ascending
filter_by = [backbone.property_name]
ascending = [backbone.ascending]
value = math.ceil(value * len(data))
if backbone.filter_on == 'Nodes':
secondary_property = None
secondary_property_ascending = None
if backbone.filter_on == 'Edges':
filter_by.append(secondary_property)
ascending.append(secondary_property_ascending)
if fraction_filter in backbone.compatible_filters():
data = data.sort_values(by=[column, secondary_property], ascending=[ascending, secondary_property_ascending])
data = data.sort_values(by=filter_by, ascending=ascending)
if narrate:
backbone.narrate()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment