Skip to content
Snippets Groups Projects

Adding new methods and the consensual backbone

Merged Ali Yassin requested to merge dev into main
1 file
+ 8
7
Compare changes
  • Side-by-side
  • Inline
+ 8
7
@@ -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()
Loading