]> gitweb.michael.orlitzky.com - sage.d.git/commitdiff
mjo/clan/clan_element.py: fix parent of inner_product()
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 10 Apr 2026 13:27:32 +0000 (09:27 -0400)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 10 Apr 2026 13:27:32 +0000 (09:27 -0400)
The inner product of two clan elements should live in the base ring of
the clan.

mjo/clan/clan_element.py

index 7c0314252d61df460336ec1c9d98f99263038057..b125d1c2e0237e97cb5b122973760f02cf6ec83e 100644 (file)
@@ -24,6 +24,7 @@ class ClanElement(IndexedFreeModuleElement):
 
         SETUP::
 
+            sage: from mjo.clan.random import random_clan
             sage: from mjo.clan.t_algebra_clan import RealSymmetricClan
 
         EXAMPLES:
@@ -39,8 +40,18 @@ class ClanElement(IndexedFreeModuleElement):
             ....:      if j == i )
             True
 
+        TESTS:
+
+        The result should live in the clan's base ring::
+
+            sage: C = random_clan()
+            sage: x = C.random_element()
+            sage: y = C.random_element()
+            sage: x.inner_product(y) in C.base_ring()
+            True
+
         """
-        return sum(
+        return self.base_ring().sum(
             xi*yj*self.parent().inner_product_on_basis(bi, bj)
             for (bi, xi) in self.items()
             for (bj, yj) in other.items()