Files
concrete/tests/common/debugging/test_drawing.py
Arthur Meyre 381c81b76c refacto: remove iter usage for passing a dataset
- it is still supported but not required and more confusing
2021-09-15 20:07:21 +02:00

29 lines
824 B
Python

"""Test file for drawing"""
import tempfile
from pathlib import Path
from concrete.common.data_types.integers import Integer
from concrete.common.debugging import draw_graph
from concrete.common.values import EncryptedScalar
from concrete.numpy.compile import compile_numpy_function_into_op_graph
def test_draw_graph_with_saving():
"""Tests drawing and saving a graph"""
def function(x):
return x + 42
op_graph = compile_numpy_function_into_op_graph(
function,
{"x": EncryptedScalar(Integer(7, True))},
[(-2,), (-1,), (0,), (1,), (2,)],
)
with tempfile.TemporaryDirectory() as tmp:
output_directory = Path(tmp)
output_file = output_directory.joinpath("test.png")
draw_graph(op_graph, save_to=output_file)
assert output_file.exists()