]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/cone/decomposition.py: handle trivial cones correctly
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 14 Nov 2025 01:21:10 +0000 (20:21 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 14 Nov 2025 01:21:10 +0000 (20:21 -0500)
mjo/cone/decomposition.py

index a21b0ec6d2056ddfc7bf7a6182b485f1a2f7b5f9..ca18b4d89d5bb5bcd4dc230a42b4a18b21fb2487 100644 (file)
@@ -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