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', ...@@ -24,7 +24,8 @@ def threshold_filter(backbone, value, narrate=True, secondary_property='weight',
ascending = backbone.ascending ascending = backbone.ascending
if threshold_filter in backbone.compatible_filters(): 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: if narrate:
backbone.narrate() backbone.narrate()
...@@ -41,17 +42,17 @@ def threshold_filter(backbone, value, narrate=True, secondary_property='weight', ...@@ -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, def fraction_filter(backbone, value, narrate=True, secondary_property='weight', secondary_property_ascending=False,
**kwargs): **kwargs):
data = backbone.to_dataframe() data = backbone.to_dataframe()
column = backbone.property_name filter_by = [backbone.property_name]
ascending = backbone.ascending ascending = [backbone.ascending]
value = math.ceil(value * len(data)) value = math.ceil(value * len(data))
if backbone.filter_on == 'Nodes': if backbone.filter_on == 'Edges':
secondary_property = None filter_by.append(secondary_property)
secondary_property_ascending = None ascending.append(secondary_property_ascending)
if fraction_filter in backbone.compatible_filters(): 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: if narrate:
backbone.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