From: Symion <kn...@ip...> - 2009-10-21 07:53:51
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> </head> <body bgcolor="#ffffff" text="#000000"> <tt>Hi there,<br> <br> I have been using Visual.random number generators and have found that the following Methods return as <br> numpy arrays, which when Printed or Evaluated returns a list that is not separated by the usual commas.<br> <br> from visual import *<br> <br> print visual.random.sample(5) # floating point list with no commas<br> print visual.random.permutation(5)</tt><tt> # Integer list with no commas</tt><br> <tt>print visual.random.randint(1,46,5)</tt><tt> # Integer list with no commas</tt><br> <tt><br> visual.safe_eval(</tt><tt>str(visual.random.randint(1,46,5))) # generates error<br> <br> </tt><tt>No commas between elements?!<br> <br> A work around is to add .tolist()<br> <br> visual.random.sample(5).tolist() # returns normal list of floats<br> visual.random.permutation(6).tolist()<br> visual.random.randint(1,46,5).tolist()<br> visual.safe_eval(str(visual.random.randint(1,46,5).tolist()))<br> <br> Symion</tt> <br> </body> </html> |