Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Added tests for invalid rule.
Browse files Browse the repository at this point in the history
  • Loading branch information
tscrim committed Apr 29, 2020
1 parent 70947de commit af577a7
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/sage/dynamics/cellular_automata/glca.py
Expand Up @@ -88,10 +88,28 @@ def __init__(self, rule):
"""
Initialize ``self``.
EXAMPLES::
TESTS::
sage: G = cellular_automata.GraftalLace([5,1,2,5,4,5,5,0])
sage: TestSuite(G).run()
sage: G = cellular_automata.GraftalLace([5,1,2,5,4,5,5])
Traceback (most recent call last):
...
ValueError: invalid rule
sage: G = cellular_automata.GraftalLace([5,1,2,5,4,5,5,0,5])
Traceback (most recent call last):
...
ValueError: invalid rule
sage: G = cellular_automata.GraftalLace([5,1,2,5,-1,5,5,0])
Traceback (most recent call last):
...
ValueError: invalid rule
sage: G = cellular_automata.GraftalLace([8,5,1,2,5,4,5,5])
Traceback (most recent call last):
...
ValueError: invalid rule
"""
if len(rule) != 8 or any(x not in range(8) for x in rule):
raise ValueError("invalid rule")
Expand Down

0 comments on commit af577a7

Please sign in to comment.