I guess I *could* write a function that prints each element
separately....
for i in range(32):
print "%.1f %.1f %.1f %.1f ..."%(m[i,0], m[i,1], m[i,2]....)
But that just seems silly.
On a related note, is there a way to change the default line width?
Even if I expand my xterm to 200+ chars, Python wraps the matrix
output at 80.
Damian Menscher
--
-=#| Physics Grad Student & SysAdmin @ U Illinois Urbana-Champaign |#=-
-=#| 488 LLP, 1110 W. Green St, Urbana, IL 61801 Ofc:(217)333-0038 |#=-
-=#| 1429 DCL, Workstation Services Group, CITES Ofc:(217)244-3862 |#=-
-=#| <mens...@uiuc.edu> www.uiuc.edu/~menscher/ Fax:(217)333-9819 |#=-
> I'm debugging my program that depends on the Numeric/LinearAlgebra
> packages. In order to get an idea of what is going on, I just use
> lots of print statements. But when you're printing a largish
> (32x32) matrix, the 8 decimal places given by default can take
> more space than they're worth. Is there a simple way to cut this
> down to a more reasonable value (like zero)?
>
> I guess I *could* write a function that prints each element
> separately....
> for i in range(32):
> print "%.1f %.1f %.1f %.1f ..."%(m[i,0], m[i,1], m[i,2]....)
> But that just seems silly.
how about a function and map:
print ' '.join(map(lambda x: "%.1f" % x, m))
> On a related note, is there a way to change the default line width?
> Even if I expand my xterm to 200+ chars, Python wraps the matrix
> output at 80.
never heard of such a restriction. do you use a specific function or
"print"? have you tried to resize first and then start python?
chris
--
Chris <clie...@gmx.net>
> I'm debugging my program that depends on the Numeric/LinearAlgebra
> packages. In order to get an idea of what is going on, I just use
> lots of print statements. But when you're printing a largish
> (32x32) matrix, the 8 decimal places given by default can take
> more space than they're worth. Is there a simple way to cut this
> down to a more reasonable value (like zero)?
>
> I guess I *could* write a function that prints each element
> separately....
> for i in range(32):
> print "%.1f %.1f %.1f %.1f ..."%(m[i,0], m[i,1], m[i,2]....)
> But that just seems silly.
>
>
> On a related note, is there a way to change the default line width?
> Even if I expand my xterm to 200+ chars, Python wraps the matrix
> output at 80.
Numeric arrays have their own printing routines, python only prints a string
it gets from them. So you'd have to hack into Numeric a bit. If you're
planning on it, let me suggest you take a look at ipython at:
http://www-hep.colorado.edu/~fperez/ipython/
I've already put in the hooks for a modified Numeric array printer, so it
would be only a matter of adding the code. The framework is in place. And for
the kind of numerical/analysis work I suspect you do, ipython has many
features which will probably help you a lot. That's my main use of it and why
I wrote it to begin with.
On a vein related to your work: I use it interactively to look at finite
temperature vacuum topology (pure gauge), here are some quick and dirty
screenshots:
http://www-hep.colorado.edu/~fperez/pub/topo_viz_sample.jpg
http://www-hep.colorado.edu/~fperez/pub/topo_2412.b585m008.36.1000.slices/
http://www-hep.colorado.edu/~fperez/pub/topo_vol_ray.jpg
The first is a single 3-d slice visualized, the second is a set of frames of
the full lattice (24^3x12) sliced along the x direction and the 3rd is a
fancy volume rendered version of the first.
If you are interested in the code to do that, drop me a line. It has already
code for loading MILC-format topological density data, and it's easy to add
writers for other formats. Its still 'internal use code', so not very
commented (right now I was modifying it to look at chiral/fermionic density)
but it should be clear enough for you to play with.
Cheers,
f.