Path: blob/main/shared/tests/test_plot.py
483 views
unlisted
"""Smoke tests for cryptolab.plot."""12import sys, os3sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))45import matplotlib6matplotlib.use('Agg') # Non-interactive backend for testing78from cryptolab.plot import (9cayley_graph, cycle_diagram, subgroup_lattice,10multiplication_heatmap, coset_coloring, graphics_array,11)121314def test_cayley_graph_returns_figure():15fig = cayley_graph(6, 1, op='add', figsize=3)16assert fig is not None1718def test_cayley_graph_non_generator():19fig = cayley_graph(6, 2, op='add', figsize=3)20assert fig is not None2122def test_cycle_diagram_returns_figure():23elements = [1, 2, 3, 4, 5, 6]24fig = cycle_diagram(7, elements, 3, op='mul', figsize=3)25assert fig is not None2627def test_subgroup_lattice_returns_figure():28fig = subgroup_lattice(12, figsize=4)29assert fig is not None3031def test_multiplication_heatmap_returns_figure():32table = [[0, 0, 0], [0, 1, 2], [0, 2, 1]]33fig = multiplication_heatmap(table, labels=[0, 1, 2], figsize=3)34assert fig is not None3536def test_coset_coloring_returns_figure():37fig = coset_coloring(12, [0, 4, 8], figsize=3)38assert fig is not None3940def test_graphics_array_returns_figure():41funcs = [42lambda ax: cayley_graph(6, 1, op='add', ax=ax),43lambda ax: cayley_graph(6, 2, op='add', ax=ax),44]45fig = graphics_array(funcs, 1, 2, figsize=(6, 3))46assert fig is not None474849