#13555: Doctests of random functions needs to be improved.
---------------------------------------------------------------------------------------------+
       Reporter:  JoalHeagney                                                   
             |         Owner:  mvngu   
           Type:  defect                                                        
             |        Status:  new     
       Priority:  major                                                         
             |     Milestone:  sage-5.5
      Component:  doctest                                                       
             |    Resolution:          
       Keywords:  random, matrices, random_matrix, properties of random 
objects, properties  |   Work issues:          
Report Upstream:  N/A                                                           
             |     Reviewers:          
        Authors:                                                                
             |     Merged in:          
   Dependencies:                                                                
             |      Stopgaps:          
---------------------------------------------------------------------------------------------+

Comment (by JoalHeagney):

 This is some code I put together to check matrix values element by
 element:

 {{{
 A = random_matrix(ZZ,5); A
 def checkfunc(matrix, func):
     for val in matrix.list():
         if func(val) == True:
             return True
     return False
 checkfunc(A, lambda x: x == 0)

 A = random_matrix(ZZ,5,x=4,y=10)
 checkfunc(A, lambda x: (x >= 4 & x < 10))

 }}}
 It's been a while since I was an efficient python programmer, so I'm sure
 someone will show me a generator/list method which is a lot more
 efficient.

 I did checkfunc as a function because I was thinking about large matricies
 and saving memory space (as well as returning on the first match to the
 conditions). I'm not satisfied with the fact that checkfunc iterates over
 a list rather than a generator.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13555#comment:4>
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