#14251: Circulant digraphs
---------------------------------+------------------------------------------
       Reporter:  ncohen         |         Owner:  jason, ncohen, rlm
           Type:  enhancement    |        Status:  needs_work        
       Priority:  major          |     Milestone:  sage-5.9          
      Component:  graph theory   |    Resolution:                    
       Keywords:                 |   Work issues:                    
Report Upstream:  N/A            |     Reviewers:  David Coudert     
        Authors:  Nathann Cohen  |     Merged in:                    
   Dependencies:                 |      Stopgaps:                    
---------------------------------+------------------------------------------

Comment (by ncohen):

 Yo !

 > * I have read somewhere that imports should now be at module level, but
 I'm not sure...

 Cython imports should be, but that's all. Anyway you cannot have all
 imports at module level, it wouldn't work. You need to use graph
 generators in digraph.py, and you need to use digraphs
 indigraph_generators too.

 > * You should test that n>=0

 Why not...

 > * You should check that integers is an iterable (list, set, dict?) with
 valid numbers (can we have negative numbers? what if a number is larger
 than n? what to do with 0?)

 If it is not iterable the "for j in integers" would fail with a clear
 message :
 {{{
 sage: digraphs.Circulant(4,5)
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)
 <ipython-input-2-50bde61731c6> in <module>()
 ----> 1 digraphs.Circulant(Integer(4),Integer(5))

 /home/ncohen/.Sage/local/lib/python2.7/site-
 packages/sage/graphs/digraph_generators.pyc in Circulant(self, n,
 integers)
     407
     408         for v in range(n):
 --> 409             G.add_edges([(v,(v+j)%n) for j in integers])
     410
     411         return G

 TypeError: 'sage.rings.integer.Integer' object is not iterable
 sage:
 }}}
 I will add some checks.. And I really hate when a 3-lines code takes 10
 lines to check bad input... Users should learn to deal with them too.

 Nathann

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14251#comment:3>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to