Raphtory icon indicating copy to clipboard operation
Raphtory copied to clipboard

Unique function for properties

Open miratepuffin opened this issue 10 months ago • 1 comments

Need to add a new function in the properties API which removes any duplicates from 'items' keeping the earliest/latest time

miratepuffin avatar Apr 22 '24 10:04 miratepuffin

unique(esarliest_time): should return the earliest entries for open, review and in-progress unique(latest_time): should return the latest entries for open, review and in-progress

g = PersistentGraph()
g.add_edge(1,1,2,properties={“status”:“open”})
g.add_edge(2,1,2,properties={“status”:“open”})
g.add_edge(3,1,2,properties={“status”:“review”})
g.add_edge(4,1,2,properties={“status”:“open”})
g.add_edge(5,1,2,properties={“status”:“in-progress”})
g.add_edge(10,1,2,properties={“status”:“in-progress”})
g.add_edge(6,1,2)

assert g.edge(1,2).properties.temporal.get(“status”).unique() == [“open”, “review”, “in-progress”]
assert g.edge(1,2).properties.temporal.get(“status”).ordered_deduple(latest_time=True) == [(2,“open”), (3“review”), (4,“open”), (10, “in-progress”)]
assert g.edge(1,2).properties.temporal.get(“status”).ordered_deduple(latest_time=False) == [(1,“open”), (3“review”), (4,“open”), (5, “in-progress”)]

shivam-880 avatar May 14 '24 12:05 shivam-880