From: Michael Orlitzky Date: Mon, 13 Feb 2017 16:30:46 +0000 (-0500) Subject: Add tests for the "K must be a Cone" TypeError. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=4332dec9566bd956c4c4cd64f30510930edc95e6;p=sage.d.git Add tests for the "K must be a Cone" TypeError. --- diff --git a/mjo/cone/cone.py b/mjo/cone/cone.py index cbbfe9b..865a070 100644 --- a/mjo/cone/cone.py +++ b/mjo/cone/cone.py @@ -74,11 +74,21 @@ def is_positive_on(L,K): ....: for L in K.positive_operators_gens() ]) # long time True + Technically we could test this, but for now only closed convex cones + are supported as our ``K`` argument:: + + sage: L = identity_matrix(3) + sage: K = [ vector([1,2,3]), vector([5,-1,7]) ] + sage: is_positive_on(L,K) + Traceback (most recent call last): + ... + TypeError: K must be a Cone. + """ if not is_Cone(K): - raise TypeError('K must be a Cone') + raise TypeError('K must be a Cone.') if not L.base_ring().is_exact() and not L.base_ring() is SR: - raise ValueError('base ring of operator L is neither SR nor exact') + raise ValueError('The base ring of L is neither SR nor exact.') if L.base_ring().is_exact(): # This should be way faster than computing the dual and @@ -159,11 +169,21 @@ def is_cross_positive_on(L,K): ....: for L in K.cross_positive_operators_gens() ]) # long time True + Technically we could test this, but for now only closed convex cones + are supported as our ``K`` argument:: + + sage: L = identity_matrix(3) + sage: K = [ vector([8,2,-8]), vector([5,-5,7]) ] + sage: is_cross_positive_on(L,K) + Traceback (most recent call last): + ... + TypeError: K must be a Cone. + """ if not is_Cone(K): - raise TypeError('K must be a Cone') + raise TypeError('K must be a Cone.') if not L.base_ring().is_exact() and not L.base_ring() is SR: - raise ValueError('base ring of operator L is neither SR nor exact') + raise ValueError('The base ring of L is neither SR nor exact.') return all([ s*(L*x) >= 0 for (x,s) in K.discrete_complementarity_set() ]) @@ -238,6 +258,16 @@ def is_Z_on(L,K): ....: for L in K.Z_operators_gens() ]) # long time True + Technically we could test this, but for now only closed convex cones + are supported as our ``K`` argument:: + + sage: L = identity_matrix(3) + sage: K = [ vector([-4,20,3]), vector([1,-5,2]) ] + sage: is_Z_on(L,K) + Traceback (most recent call last): + ... + TypeError: K must be a Cone. + """ return is_cross_positive_on(-L,K) @@ -317,11 +347,21 @@ def is_lyapunov_like_on(L,K): ....: for L in K.lyapunov_like_basis() ]) # long time True + Technically we could test this, but for now only closed convex cones + are supported as our ``K`` argument:: + + sage: L = identity_matrix(3) + sage: K = [ vector([2,2,-1]), vector([5,4,-3]) ] + sage: is_lyapunov_like_on(L,K) + Traceback (most recent call last): + ... + TypeError: K must be a Cone. + """ if not is_Cone(K): - raise TypeError('K must be a Cone') + raise TypeError('K must be a Cone.') if not L.base_ring().is_exact() and not L.base_ring() is SR: - raise ValueError('base ring of operator L is neither SR nor exact') + raise ValueError('The base ring of L is neither SR nor exact.') return all([ s*(L*x) == 0 for (x,s) in K.discrete_complementarity_set() ])