I opened a ticket (trac #13119) and added a patch to the combinat series. I have not added the patch to the trac server yet.
-Mike On Friday, 15 June 2012 12:26:02 UTC-4, Franco Saliola wrote: > > On Fri, Jun 15, 2012 at 10:36 AM, Mike Zabrocki <[email protected]> > wrote: > > I agree with you that __len__ should be removed, especially if len( > > finiteclass ) returns a value. But even if it doesn't then the correct > > method to use is finiteclass.cardinality() anyway. Right? > > > > About this ._apply_module_morphism() fix though. The segment of code > that > > is is in combinat/free_module.py currently reads: > > > > if x == self.zero(): > > if not codomain: > > B = self.basis() > > keys = list( B.keys() ) > > if len( keys ) > 0: > > key = keys[0] > > codomain = on_basis( key ).parent() > > else: > > raise ValueError, 'Codomain could not be determined' > > > > return codomain.zero() > > > > That is, it is trying to determine the codomain by picking an element of > the > > domain. But in the case when the domain doesn't exist (when would this > > happen? I don't know how to trigger this) it raises a value error. Can > I > > replace this with the code?: > > > > if x == self.zero(): > > if not codomain: > > B = self.basis() > > codomain = on_basis( B.first() ).parent() > > > > return codomain.zero() > > This looks good. I see two minor issues. > > 1) It will raise an error when B.first() is not defined. But > self.basis() returns a Family, so it shouldn't happen unless a user > redefines self.basis(). We could support this with the following: > > B = Family(self.basis()) > > which will work provided that self.basis() is iterable. > > 2) Another issue is that the domain may be 0-dimensional: > > sage: F = CombinatorialFreeModule(QQ, []) > sage: F.basis() > Finite family {} > sage: F.basis().first() > Traceback (most recent call last): > ... > StopIteration > > Should we worry about this? We could use a try-except statement to > catch this error: > > if not codomain: > B = Family(self.basis()) > try: > z = B.first() > except StopIteration: > raise ValueError, 'Codomain could not be determined' > codomain = on_basis(z).parent() > > Franco > > -- > -- You received this message because you are subscribed to the Google Groups "sage-combinat-devel" group. To view this discussion on the web visit https://groups.google.com/d/msg/sage-combinat-devel/-/MRlXEQWBz60J. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sage-combinat-devel?hl=en.
