#13204: Element construction for CrystalOfTableaux should be robust versus  
int's
----------------------------------+-----------------------------------------
       Reporter:  nthiery         |         Owner:  sage-combinat    
           Type:  defect          |        Status:  needs_info       
       Priority:  major           |     Milestone:  sage-5.6         
      Component:  combinatorics   |    Resolution:                   
       Keywords:                  |   Work issues:                   
Report Upstream:  N/A             |     Reviewers:  Nicolas M. ThiƩry
        Authors:  Anne Schilling  |     Merged in:                   
   Dependencies:                  |      Stopgaps:                   
----------------------------------+-----------------------------------------
Changes (by tscrim):

  * status:  new => needs_info


Comment:

 Another (more subtle) bug which comes from the same issue:

 {{{
 sage: C = KirillovReshetikhinCrystal(['A',int(4),1], 1,1)
 sage: C[0].e0()
 # Boom
 AttributeError: 'int' object has no attribute 'epsilon'
 }}}
 The problem seems to be in that elements are created from
 `C.cartan_type().n` somewhere (I didn't track this down).

 I've uploaded my fix for this which automatically calls the
 `CrystalOfLetters` on each element in the list (which should just type
 check and return the element back if it already is a letter). There is a
 slight performance hit (see below) for doing this rather than just
 checking the leading element. Also this takes care of input like:

 {{{
 sage: t = T(list=[T.letters(3),1,4,2])
 sage: t = T(list=[CrystalOfLetters(['D',6])(3),1,4,2])
 }}}
 (Note CrystalOfLetters checks (well lack thereof) are not robust enough to
 catch the second input as an error, but that's a separate issue.) Really
 the question boils down to how pathological do we think the users might be
 with this versus the speed hit? If people think this is a good fix, this
 is ready to review.

 Thanks,[[BR]] Travis

 Performance data before patch:
 {{{
 sage: B = KirillovReshetikhinCrystal(['A',4,1], 3,3)

 sage: %timeit L = [x for x in B]
 5 loops, best of 3: 584 ms per loop
 sage: %timeit L = [x for x in B]
 5 loops, best of 3: 550 ms per loop

 sage: %prun L = [x for x in B]
    398355 function calls in 4.147 seconds

    Ordered by: internal time

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     45228    0.668    0.000    1.602    0.000 crystals.py:169(index_set)
     45053    0.658    0.000    2.433    0.000 crystals.py:727(index_set)
     45228    0.443    0.000    0.680    0.000
 cartan_type.py:1822(index_set)
 ...
 }}}
 after patch:

 {{{
 sage: B = KirillovReshetikhinCrystal(['A',4,1], 3,3)

 sage: %timeit L = [x for x in B]
 5 loops, best of 3: 642 ms per loop
 sage: %timeit L = [x for x in B]
 5 loops, best of 3: 633 ms per loop

 sage: %prun L = [x for x in B]
    426299 function calls in 5.135 seconds

    Ordered by: internal time

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     45228    0.791    0.000    1.942    0.000 crystals.py:167(index_set)
     45053    0.728    0.000    2.874    0.000 crystals.py:726(index_set)
     45228    0.572    0.000    0.838    0.000
 cartan_type.py:1822(index_set)
 ...
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13204#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en.

Reply via email to