From: Michael Orlitzky Date: Fri, 14 Nov 2025 01:21:10 +0000 (-0500) Subject: mjo/cone/decomposition.py: handle trivial cones correctly X-Git-Url: http://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=b8c1c05692272d64a3cece0f6bceffd75b23b4c3;p=sage.d.git mjo/cone/decomposition.py: handle trivial cones correctly --- diff --git a/mjo/cone/decomposition.py b/mjo/cone/decomposition.py index a21b0ec..ca18b4d 100644 --- a/mjo/cone/decomposition.py +++ b/mjo/cone/decomposition.py @@ -160,11 +160,25 @@ def irreducible_factors(K): ValueError: cone must be strictly convex (AKA pointed) for its irreducible factors to be well-defined + Trivial cones are handled correctly:: + + sage: K = cones.trivial(0) + sage: irreducible_factors(K) == {K} + True + sage: K = cones.trivial(4) + sage: irreducible_factors(K) == {K} + True + """ if not K.is_strictly_convex(): raise ValueError("cone must be strictly convex (AKA pointed) for" " its irreducible factors to be well-defined") + if K.is_trivial(): + # Trivial cones are valid inputs, but they have no generators + # so a special case is required. + return {K} + V = K.ambient_vector_space() # Create a column matrix from the generators of K, and then