LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-04-2011, 02:22 AM   #1
cin_
Member
 
Registered: Dec 2010
Posts: 266

Rep: Reputation: 23
python : NumPy : Array, Matrix Formatting


pour posteritie,


Formatting with NumPy ...
"
One dimensional arrays are then printed as rows, bidimensionals as matrices and tridimensionals as lists of matrices.
"


Code is essentially...
Code:
import numpy as whatisgoingonwiththeformattingofmy
print 33
pseudomatrix = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32] -- this repeats itself 29 times... -- [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
]
print whatisgoingonwiththeformattingofmy.array([pseudomatrix])

And the output is...
Code:
# ./pseudomatrix
33
[[ 0  0  0 ...,  0  0  0]
 [ 0  1  2 ..., 30 31 32]
 [ 0  1  2 ..., 30 31 32]
 ..., 
 [ 0  1  2 ..., 30 31 32]
 [ 0  1  2 ..., 30 31 32]
 [ 0  1  2 ..., 30 31 32]]
To remove this formatting built in,
Add this, or some variant, to your code...
Code:
import numpy as whatisgoingonwiththeformattingofmy
set_printoptions(threshold='nan')
set_printoptions(linewidth=100)
...

set_printoptions() : http://docs.scipy.org/doc/numpy/refe...ntoptions.html

Last edited by cin_; 08-05-2011 at 08:03 PM. Reason: gramm`err
 
Old 08-05-2011, 12:25 AM   #2
EricTRA
Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290Reputation: 1290
Hi,

Thanks for sharing. Off the Zero Reply List.

Kind regards,

Eric
 
Old 08-05-2011, 07:56 PM   #3
cin_
Member
 
Registered: Dec 2010
Posts: 266

Original Poster
Rep: Reputation: 23
Documentation

It originally began as a question.

I searched the forum and could not find anything... I am not authorised to create my own tags, but I though NumPy would have been a good tag for this post... so I decided to dig through the documentation.

Some time later I thought I'd share the conclusions to save others the time and give the forum another search result.

Last edited by cin_; 08-05-2011 at 08:00 PM. Reason: gramm`err
 
  


Reply

Tags
array, formatting, matrix, python


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
python/numpy on RHEL6.1 - installed RPMS not compiled from source netnix99 Linux - Software 4 07-06-2011 01:30 PM
Installing Python NUMPY on Godaddy server strimp099 Linux - Server 0 02-12-2011 07:03 AM
Installing python-numpy in the python2.5 installation of eee-pc zoopside Linux - Software 3 04-01-2009 07:42 PM
python error , import numpy ufmale Programming 2 08-25-2008 11:59 PM
Visual Python/Numpy uranologist Linux - Software 0 09-28-2003 10:08 PM


All times are GMT -5. The time now is 01:36 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration