Hi, what is the best way to print (to a file or to stdout) formatted
numerical values? Analogously to C's printf(%d %g,x,y) etc?
Numpy Documentation only discusses input *from* a file, or output of
entire arrays. (np.savetxt()) I just want tab or space-delimited output of
selected formatted
On 15 November 2010 15:32, pv+nu...@math.duke.edu wrote:
Hi, what is the best way to print (to a file or to stdout) formatted
numerical values? Analogously to C's printf(%d %g,x,y) etc?
Use the .tofile() method:
numpy.random.random(5).tofile(sys.stdout, ' ', '%s')
0.230466435867
On Mon, Nov 15, 2010 at 08:32, pv+nu...@math.duke.edu wrote:
Hi, what is the best way to print (to a file or to stdout) formatted
numerical values? Analogously to C's printf(%d %g,x,y) etc?
Numpy Documentation only discusses input *from* a file, or output of
entire arrays. (np.savetxt()) I
pv+numpy at math.duke.edu writes:
Hi, what is the best way to print (to a file or to stdout) formatted
numerical values? Analogously to C's printf(%d %g,x,y) etc?
For stdout you can simply do:
In [26]: w, x, y, z = np.randint(0,100,4)
In [27]: type(w)
Out[27]: type 'numpy.int32'
In
Is there a convention for dealing with NaN and Inf? I've found that
trusting the default behavior is a very bad idea:
---
from numpy import *
x = zeros((5,7))
x[:,3:] = nan
x[:,-1] = inf
savetxt('problem_array.txt',x,delimiter='\t')
x2 =