Skip to content

Pin how filters combine at every place a filter is applied - #2959

Open
shivamka1 wants to merge 13 commits into
db_v4from
test/filter-combination-matrix
Open

shivamka1 wants to merge 13 commits into
db_v4from
test/filter-combination-matrix

Conversation

@shivamka1

@shivamka1 shivamka1 commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Adds a matrix of the filters Raphtory refuses today, as tests. When a refused filter becomes supported, its row fails and names the filter and the site, so the change is made on purpose.

Sites. 14 of them, in three groups that behave alike: .filter(f) on a graph, nodes, a node, neighbours, edges or an edge; [f] on nodes or neighbours; [f] on edges or exploded edges.

Table or test Pins
COMBINATIONS every kind of part (node, edge and update tests; time, layer and other views), alone, negated and in pairs under &, | and ~, with every part of each kind: the refusal at each site, or none, on Graph and PersistentGraph
NESTED 11 filters nested deeper than a pair: the refusal at each site, or none
expected failure #2952: g.edges.filter(f).explode() lists updates f hides

with_variants now passes a test's arguments through, so it can be combined with pytest.mark.parametrize.

Closes #2965

The window [2, 9) held every node, so `window` and `score | window` kept
all five. [2, 7) leaves e outside and d only inside. Also pins what a
negated view keeps against a negated existence test, and the accepted
forms of the refused negations of views.
Seven entries of `BLOCKS` repeated the expressions of `score`, `person`,
`heavy`, `update`, `window`, `work` and `abc`. They now name those
functions.
One table, EXPECTED, says per named filter what each site keeps or the
refusal it gives, replacing the separate acceptance and kept tables.
Rows are written with refused(on_filter=, on_nodes=, on_edges=,
everywhere=) and ACCEPTED, and the sites are grouped as ON_FILTER,
ON_NODES and ON_EDGES.
SHAPES becomes FILTERS and BLOCKS becomes PARTS, in the shared module,
the matrix tests and the parity tests.
with_variants passes the test's arguments through, so the table tests
can be parametrized and a failure names the filter and site it is about.
The matrix says which filters are refused and where. What accepted
filters keep, the negation and distribution laws and the server parity
run are covered by other suites and leave this file, and with one file
left the fixture and the parts move into it. The sites of filter() on a
graph become one site, since a refusal is raised by the call itself.
The exploded listing of a filtered edge collection is an expected
failure of its own.

@ljeub-pometry ljeub-pometry left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a lot more structure so we can easily keep this up-to-date!

"graph.filter": lambda graph, expr: graph.filter(expr),
"nodes.filter": lambda graph, expr: graph.nodes.filter(expr),
"node.filter": lambda graph, expr: graph.node("a").filter(expr),
"neighbours.filter": lambda graph, expr: graph.nodes.neighbours.filter(expr),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing the PathFromNode, i.e., graph.node("a").neighbours.filter(expr)

"node.filter": lambda graph, expr: graph.node("a").filter(expr),
"neighbours.filter": lambda graph, expr: graph.nodes.neighbours.filter(expr),
"edges.filter": lambda graph, expr: graph.edges.filter(expr),
"edge.filter": lambda graph, expr: graph.edge("a", "b").filter(expr),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is missing the NestedEdges, i.e., graph.nodes.edges.filter(expr)

Comment on lines +163 to +164
"neighbours[]": lambda graph, expr: graph.nodes.neighbours[expr],
"node.neighbours[]": lambda graph, expr: graph.node("a").neighbours[expr],

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neighbours are different from nodes once the path filtering is fixed (see #2924), it is probably worth splitting them out now!

Comment on lines +55 to +82

def score():
return Node.property("score") > 15


def person():
return Node.node_type() == "person"


def heavy():
return Edge.property("w") > 3


def update():
return ExplodedEdge.property("w") > 3


def window():
return GraphView.window(2, 7)


def work():
return GraphView.layer("work")


def abc():
return GraphView.subgraph(["a", "b", "c"])

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are these named functions instead of lambdas as everything else?

}

# Where each form is refused, for each kind of part it is filled with.
COMBINATIONS = {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structure makes it really non-obvious that everything is covered and very annoying to add anything. This should be structured in a nested way so we have a mapping from Form -> test type -> (examples, expected result). Using data classes to fix the structure would be very helpful as well!

The parts and the nested filters are lambdas like everything else in the file, instead of named helper functions.
SINGLE and PAIRS map each form to its test types (or pair of test types) and to where the filter is refused at each group of sites, through the ByType, BySite and Form dataclasses. ByType has a required field per test type, so a form that leaves one out fails at import and the coverage test goes. Each ordered pair of test types has its own cell.
node.neighbours.filter (PathFromNode) joins the filter sites.
nodes.edges.filter (NestedEdges) joins the filter sites.
neighbours[] and node.neighbours[] move out of the nodes group into their own, as neighbours will be filtered differently from nodes once path filtering is fixed (#2924).

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Record which filter combinations are refused today, as tests

2 participants