-
-
Notifications
You must be signed in to change notification settings - Fork 773
Description
Various people worked on factorization.py and unfortunately ignored some implicit
assumptions in what that code is supposed to do. In particular, this function
def base_ring(self):
if len(self) > 0:
return self[0][0].parent()
else:
return self.unit().parent()
assumes that (1) ever element has the same parent, and (2) the parent is a ring.
Neither assumption need be satisfied.
This is_commutative function then relies on base_ring working.
Here's an example of this leading to wrong answers:
sage: R.<x,y> = FreeAlgebra(QQ,2)
sage: Factorization([(3,1), (x,2), (y,3), (x,1), (y,2)])
3 * x^3 * y^5
Proposal: Simply call Sequence on the list of bases in the factorization
to get a new list where the basis lie in a common university. Then refine
is_commutative to mean that the universe is a commuative ring, and only then
commute factors automatically.
Second, after the above is resolved, the sort function for comparison
should call universe() (not base_ring) and use some sensible defaults,
before resorting to that mess of code in the current sort method.
Component: basic arithmetic
Keywords: editor_wstein
Issue created by migration from https://trac.sagemath.org/ticket/2460