From 2a041fb3fc70f562503f1e4dbacfc38a1fa958e9 Mon Sep 17 00:00:00 2001 From: David Lucas Date: Thu, 21 Jan 2016 13:57:48 +0100 Subject: [PATCH] Fixed check on the input space --- src/sage/coding/channel_constructions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sage/coding/channel_constructions.py b/src/sage/coding/channel_constructions.py index 5253243887a..ddfbaaff8ad 100644 --- a/src/sage/coding/channel_constructions.py +++ b/src/sage/coding/channel_constructions.py @@ -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:: @@ -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"""