Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
duyuefeng0708
GitHub Repository: duyuefeng0708/Cryptography-From-First-Principle
Path: blob/main/shared/tests/test_plot.py
483 views
unlisted
1
"""Smoke tests for cryptolab.plot."""
2
3
import sys, os
4
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
5
6
import matplotlib
7
matplotlib.use('Agg') # Non-interactive backend for testing
8
9
from cryptolab.plot import (
10
cayley_graph, cycle_diagram, subgroup_lattice,
11
multiplication_heatmap, coset_coloring, graphics_array,
12
)
13
14
15
def test_cayley_graph_returns_figure():
16
fig = cayley_graph(6, 1, op='add', figsize=3)
17
assert fig is not None
18
19
def test_cayley_graph_non_generator():
20
fig = cayley_graph(6, 2, op='add', figsize=3)
21
assert fig is not None
22
23
def test_cycle_diagram_returns_figure():
24
elements = [1, 2, 3, 4, 5, 6]
25
fig = cycle_diagram(7, elements, 3, op='mul', figsize=3)
26
assert fig is not None
27
28
def test_subgroup_lattice_returns_figure():
29
fig = subgroup_lattice(12, figsize=4)
30
assert fig is not None
31
32
def test_multiplication_heatmap_returns_figure():
33
table = [[0, 0, 0], [0, 1, 2], [0, 2, 1]]
34
fig = multiplication_heatmap(table, labels=[0, 1, 2], figsize=3)
35
assert fig is not None
36
37
def test_coset_coloring_returns_figure():
38
fig = coset_coloring(12, [0, 4, 8], figsize=3)
39
assert fig is not None
40
41
def test_graphics_array_returns_figure():
42
funcs = [
43
lambda ax: cayley_graph(6, 1, op='add', ax=ax),
44
lambda ax: cayley_graph(6, 2, op='add', ax=ax),
45
]
46
fig = graphics_array(funcs, 1, 2, figsize=(6, 3))
47
assert fig is not None
48
49