Visit the LQ Articles and Editorials section
 Home Forums HCL Reviews Tutorials Articles Register Search Today's Posts Mark Forums Read
 LinuxQuestions.org [SOLVED] python : NumPy : Array, Matrix Formatting
 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

 08-04-2011, 02:22 AM #1 cin_ Member   Registered: Dec 2010 Posts: 266 Rep: 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
 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: Hi, Thanks for sharing. Off the Zero Reply List. Kind regards, Eric
 08-05-2011, 07:56 PM #3 cin_ Member   Registered: Dec 2010 Posts: 266 Original Poster Rep: 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

 Tags array, formatting, matrix, python