mirror of
https://github.com/zama-ai/concrete.git
synced 2026-02-09 03:55:04 -05:00
- add BaseTracer which will hold most of the boilerplate code - add hnumpy with a bare NPTracer and tracing function - update IR to be compatible with tracing helpers - update test helper to properly check that graphs are equivalent - add test tracing a simple addition - rename common/data_types/helpers.py to .../dtypes_helpers.py to avoid having too many files with the same name - ignore missing type stubs in the default mypy command - add a comfort Makefile target to get errors about missing mypy stubs
32 lines
958 B
Python
32 lines
958 B
Python
"""PyTest configuration file"""
|
|
import networkx as nx
|
|
import networkx.algorithms.isomorphism as iso
|
|
import pytest
|
|
|
|
|
|
class TestHelpers:
|
|
"""Class allowing to pass helper functions to tests"""
|
|
|
|
@staticmethod
|
|
def digraphs_are_equivalent(reference: nx.MultiDiGraph, to_compare: nx.MultiDiGraph):
|
|
"""Check that two digraphs are equivalent without modifications"""
|
|
# edge_match is a copy of node_match
|
|
edge_matcher = iso.categorical_multiedge_match("input_idx", None)
|
|
node_matcher = iso.generic_node_match(
|
|
"content", None, lambda lhs, rhs: lhs.is_equivalent_to(rhs)
|
|
)
|
|
graphs_are_isomorphic = nx.is_isomorphic(
|
|
reference,
|
|
to_compare,
|
|
node_match=node_matcher,
|
|
edge_match=edge_matcher,
|
|
)
|
|
|
|
return graphs_are_isomorphic
|
|
|
|
|
|
@pytest.fixture
|
|
def test_helpers():
|
|
"""Fixture to return the static helper class"""
|
|
return TestHelpers
|