Hello all,

Recently, we noticed a problem with CombinatorialFreeModule and
doctests.  Say in one doctest, you have

            sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
            sage: F.print_options(monomial_cmp = lambda x,y: -cmp(x,y))

This F is cached in CombinatorialFreeModule.__classcall__.cache along
with the lambda function whose scope is tied to the global scope in
which it was defined.  In a later doctest, we have

            sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
            sage: F._sum_of_monomial(['a', 'b'])

which will try to use the previous lambda function for monomial_cmp
while printing the answer.  However, the doctest framework clears the
globals dictionary at the end of each "block" of doctests in order to
facilitate garbage collection.  Thus, the lambda function will fail to
evaluate (because it can't even look up cmp) and this is caught in
f._sorted_items_for_printing.  The element then (possibly) gets
printed incorrectly.

Proposal:  One way to fix this, and maybe remove some confusion since
these cached objects are mutable is to remove it from the cache when a
print_option is set.

Thoughts?

--Mike

-- 
You received this message because you are subscribed to the Google Groups 
"sage-combinat-devel" group.
To post to this group, send email to sage-combinat-devel@googlegroups.com.
To unsubscribe from this group, send email to 
sage-combinat-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sage-combinat-devel?hl=en.

Reply via email to