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 = loadtxt('problem_array.txt'
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]:
In [28]: print("%f %g %e %d"
On Mon, Nov 15, 2010 at 08:32, 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 just want tab or
On 15 November 2010 15:32, 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 0.609443784908 0.353855676828 0.
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 v