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

Commit 9a22432

Browse files
author
David Lucas
committed
Added checks on the input
1 parent e52e959 commit 9a22432

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/sage/coding/channel_constructions.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,15 @@ class QarySymmetricChannel(Channel):
732732

733733
def __init__(self, space, epsilon):
734734
r"""
735+
TESTS:
735736
737+
If ``space`` is not a vector space, an error is raised::
736738
737-
TESTS:
739+
sage: epsilon = 0.42
740+
sage: Chan = channels.QarySymmetricChannel(GF(59), epsilon)
741+
Traceback (most recent call last):
742+
...
743+
ValueError: The input space has to be a vector space
738744
739745
If ``epsilon`` is not between 0 and 1, an error is raised::
740746
@@ -744,6 +750,10 @@ def __init__(self, space, epsilon):
744750
...
745751
ValueError: Error probability must be between 0 and 1
746752
"""
753+
if not hasattr(V, "dimension"):
754+
raise ValueError("The input space has to be a vector space")
755+
if not hasattr(V.base_field(), "random_element"):
756+
raise ValueError("The base field of the input space must have random_element method")
747757
if epsilon >= 1 or epsilon <= 0:
748758
raise ValueError("Error probability must be between 0 and 1")
749759

@@ -815,7 +825,7 @@ def transmit_unsafe(self, message):
815825

816826
def error_probability(self):
817827
r"""
818-
Returns the error probability of an single symbol transmission of
828+
Returns the error probability of a single symbol transmission of
819829
``self``.
820830
821831
EXAMPLES::

0 commit comments

Comments
 (0)