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

Commit

Permalink
Fixed check on the input space
Browse files Browse the repository at this point in the history
  • Loading branch information
David Lucas committed Jan 21, 2016
1 parent 35fa1fd commit 2a041fb
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sage/coding/channel_constructions.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def __init__(self, space, epsilon):
sage: Chan = channels.QarySymmetricChannel(GF(59), epsilon)
Traceback (most recent call last):
...
ValueError: The input space has to be a vector space
ValueError: space has to be of the form Sigma^n, where Sigma has a random_element() method
If ``epsilon`` is not between 0 and 1, an error is raised::
Expand All @@ -715,15 +715,15 @@ def __init__(self, space, epsilon):
...
ValueError: Error probability must be between 0 and 1
"""
if not hasattr(space, "dimension"):
raise ValueError("The input space has to be a vector space")
if not hasattr(space.base_field(), "random_element"):
raise ValueError("The base field of the input space must have random_element method")
if epsilon >= 1 or epsilon <= 0:
raise ValueError("Error probability must be between 0 and 1")

super(QarySymmetricChannel, self).__init__(space, space)
self._epsilon = epsilon
try:
self.transmit_unsafe(space.random_element())
except:
raise ValueError("space has to be of the form Sigma^n, where Sigma has a random_element() method")

def __repr__(self):
r"""
Expand Down

0 comments on commit 2a041fb

Please sign in to comment.