Opened 9 years ago

Last modified 8 years ago

#15349 needs_info enhancement

values() method for lazy families

Reported by: Darij Grinberg Owned by:
Priority: major Milestone: sage-6.4
Component: categories Keywords: family, lazy family, free module
Cc: Florent Hivert, Nicolas M. Thiéry, Sage Combinat CC user, Travis Scrimshaw Merged in:
Authors: Darij Grinberg Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


The attached patch provides a values() method for lazy families. While not very useful in the infinite case, it helps avoiding things like this:

sage: SymmetricGroupAlgebra(QQ, 4).gens()
AttributeError                            Traceback (most recent call last)
<ipython-input-3-14b6bd4b0e1d> in <module>()
----> 1 SymmetricGroupAlgebra(QQ, Integer(4)).gens()

/home/darij/sage-5.13.beta0/local/lib/python2.7/site-packages/sage/combinat/free_module.pyc in gens(self)
   1616             (B['a'], B['b'], B['c'])
   1617         """
-> 1618         return tuple(self.basis().values())
   1620     def set_order(self, order):

/home/darij/sage-5.13.beta0/local/lib/python2.7/site-packages/sage/structure/ in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6823)()

/home/darij/sage-5.13.beta0/local/lib/python2.7/site-packages/sage/structure/ in sage.structure.misc.getattr_from_other_class (sage/structure/misc.c:1606)()

AttributeError: 'LazyFamily_with_category' object has no attribute 'values'

(The gens method on combinatorial free modules was introduced in #13214, and returns tuple(self.basis().values()), so the error appears every time a basis is a lazy family rather than a regular finite family, even if the lazy family is finite!) Of course, the symmetric group algebra has a more economical generating set than this, but I assume other combinatorial free modules still profit from this.

(That said, I never understood how to tell from inside code whether gens() returns an algebra generating set or a module generating set... Can anyone enlighten me on that?)

Someone please assure me whether the keys of a lazy(!) family can be assumed ordered. They seem to be stored as a set, which I never fully understood. If their order is system-dependent, that should probably be said in the doc of the values() method.

The patch also removes some warnings which were made over 4 years ago (#5538).

Attachments (1)

trac_15349-lazy-family-values-dg.patch (16.3 KB) - added by Darij Grinberg 9 years ago.

Download all attachments as: .zip

Change History (11)

Changed 9 years ago by Darij Grinberg

comment:1 Changed 9 years ago by Darij Grinberg

Status: newneeds_review

comment:2 Changed 9 years ago by Darij Grinberg

Authors: Darij GRinbergDarij Grinberg

comment:3 Changed 9 years ago by Nicolas M. Thiéry

I think it's CombinatorialFreeModule? that should be fixed to not use .values() but instead

    return tuple(self.basis())

By the way, this gens method would fit better in the ModulesWithBasis? category (with a sanity check that it's not infinite dimensional), or better in ModulesWithBasis?.FiniteDimensional? (note: check for potential conflicts with #11111).

comment:4 Changed 9 years ago by Darij Grinberg

OK; I'll rather leave this to you people. But are the changes I've done here any good?

comment:5 Changed 9 years ago by Nicolas M. Thiéry

Hi Darij!

Unless we later find a compelling use case, I'd say for now it's just a temporary workaround; so keep it around for yourself, or even push it in the "queue" (or whatever will happen to it); but for now I would not get this change in Sage unless it's really needed for some other ticket.



comment:6 Changed 9 years ago by Darij Grinberg

Hi Nicolas,

thanks for looking into it. I'll change status to "new" then.
I probably am not going to do anything about ModulesWithBasis? myself, but I'd welcome any improvements on that class.

Best regards,

comment:7 Changed 9 years ago by Darij Grinberg

Status: needs_reviewneeds_info

comment:8 Changed 9 years ago by For batch modifications

Milestone: sage-6.1sage-6.2

comment:9 Changed 9 years ago by For batch modifications

Milestone: sage-6.2sage-6.3

comment:10 Changed 8 years ago by For batch modifications

Milestone: sage-6.3sage-6.4
Note: See TracTickets for help on using tickets.