From b8c1c05692272d64a3cece0f6bceffd75b23b4c3 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 13 Nov 2025 20:21:10 -0500 Subject: [PATCH] mjo/cone/decomposition.py: handle trivial cones correctly --- mjo/cone/decomposition.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- 2.51.0