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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
08-04-2011, 02:22 AM
|
#1
|
|
Member
Registered: Dec 2010
Posts: 179
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
|
|
Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 18 with Awesome WM
Posts: 6,796
|
Hi,
Thanks for sharing. Off the Zero Reply List.
Kind regards,
Eric
|
|
|
|
08-05-2011, 07:56 PM
|
#3
|
|
Member
Registered: Dec 2010
Posts: 179
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
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:28 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|