473,406 Members | 2,220 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How do I print a numpy array?

How do you print a numpy array?

I tried the obvious print a, print `a`, and print str(a), but
none of them work on anything other than trivially small
arrays. Most of my real data is elided and replaced with
ellipses.

--
Grant Edwards grante Yow! I want to kill
at everyone here with a cute
visi.com colorful Hydrogen Bomb!!
Dec 1 '06 #1
8 7738
Grant Edwards wrote:
How do you print a numpy array?

I tried the obvious print a, print `a`, and print str(a), but
none of them work on anything other than trivially small
arrays. Most of my real data is elided and replaced with
ellipses.
You might want to ask numpy questions on the numpy list:

http://www.scipy.org/Mailing_Lists

Use numpy.set_printoptions(threshold=sys.maxint) to disable all summarization.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 1 '06 #2
On 2006-12-01, Robert Kern <ro*********@gmail.comwrote:
Grant Edwards wrote:
>How do you print a numpy array?
You might want to ask numpy questions on the numpy list:

http://www.scipy.org/Mailing_Lists
I tried, but it doesn't seem to be available through gmane.org.
Use numpy.set_printoptions(threshold=sys.maxint) to disable
all summarization.
Thanks.

--
Grant Edwards grante Yow! I've got to get
at these SNACK CAKES to NEWARK
visi.com by DAWN!!
Dec 1 '06 #3

Robert Kern wrote:
Grant Edwards wrote:
How do you print a numpy array?

I tried the obvious print a, print `a`, and print str(a), but
none of them work on anything other than trivially small
arrays. Most of my real data is elided and replaced with
ellipses.

You might want to ask numpy questions on the numpy list:

http://www.scipy.org/Mailing_Lists

Use numpy.set_printoptions(threshold=sys.maxint) to disable all summarization.
When I print an array in any language, I (and I think most programmers)
expect by default to have all elements displayed. Matlab, R, and
Fortran 95 have somewhat similar arrays to numpy, and that is what they
do. I don't remember Numeric summarizing arrays by default. R has a
"summary" function as well as a "print" function.

Dec 1 '06 #4
Grant Edwards wrote:
On 2006-12-01, Robert Kern <ro*********@gmail.comwrote:
>Grant Edwards wrote:
>>How do you print a numpy array?
>You might want to ask numpy questions on the numpy list:

http://www.scipy.org/Mailing_Lists

I tried, but it doesn't seem to be available through gmane.org.
Yes, it is.

http://dir.gmane.org/gmane.comp.python.numeric.general

Did you have a specific problem accessing it? I can access it just fine. I think
you may have to subscribe to the list to post (otherwise we get too much spam).
Of course, you can turn off mail delivery if you only want to go through GMane.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 2 '06 #5
Beliavsky wrote:
When I print an array in any language, I (and I think most programmers)
expect by default to have all elements displayed. Matlab, R, and
Fortran 95 have somewhat similar arrays to numpy, and that is what they
do. I don't remember Numeric summarizing arrays by default. R has a
"summary" function as well as a "print" function.
There are pretty serious problems with interactive use and large arrays.
Formatting the string for a very large array can take a fair bit of time, often
much more than the computation that generated it. This has been a long-standing
frustration of many Numeric users. At the interactive prompt, if the statement
you just entered is taking a long time to execute and you Ctrl-C, odds are, the
traceback points you right in the middle of array2string(), not anything in the
actual computation itself. Since the interactive prompt prints things out
without the user explicitly asking for it, it's not enough simply to have two
functions available.

numarray set the default to summarize, and numpy kept numarray's choice.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 2 '06 #6
On 2006-12-02, Robert Kern <ro*********@gmail.comwrote:
Grant Edwards wrote:
>On 2006-12-01, Robert Kern <ro*********@gmail.comwrote:
>>Grant Edwards wrote:
How do you print a numpy array?
>>You might want to ask numpy questions on the numpy list:

http://www.scipy.org/Mailing_Lists

I tried, but it doesn't seem to be available through gmane.org.

Yes, it is.

http://dir.gmane.org/gmane.comp.python.numeric.general
I was looking for the "numpy-discussion" mailing list. It
didn't occur to me that it was spelled "numeric.general".

--
Grant Edwards grante Yow! Th' MIND is the Pizza
at Palace of th' SOUL
visi.com
Dec 2 '06 #7
Grant Edwards wrote:
On 2006-12-02, Robert Kern <ro*********@gmail.comwrote:
>Grant Edwards wrote:
>>On 2006-12-01, Robert Kern <ro*********@gmail.comwrote:
Grant Edwards wrote:
How do you print a numpy array?
You might want to ask numpy questions on the numpy list:

http://www.scipy.org/Mailing_Lists
I tried, but it doesn't seem to be available through gmane.org.
Yes, it is.

http://dir.gmane.org/gmane.comp.python.numeric.general

I was looking for the "numpy-discussion" mailing list. It
didn't occur to me that it was spelled "numeric.general".
Yeah, GMane likes to apply their own naming system. Fortunately, they have a
little search tool that will locate the right newsgroup given "numpy-discussion":

http://gmane.org/find.php

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Dec 2 '06 #8
On 2006-12-02, Robert Kern <ro*********@gmail.comwrote:
Beliavsky wrote:
>When I print an array in any language, I (and I think most programmers)
expect by default to have all elements displayed. Matlab, R, and
Fortran 95 have somewhat similar arrays to numpy, and that is what they
do. I don't remember Numeric summarizing arrays by default. R has a
"summary" function as well as a "print" function.

There are pretty serious problems with interactive use and large arrays.
Formatting the string for a very large array can take a fair bit of time, often
much more than the computation that generated it. This has been a long-standing
frustration of many Numeric users. At the interactive prompt, if the statement
you just entered is taking a long time to execute and you Ctrl-C, odds are, the
traceback points you right in the middle of array2string(), not anything in the
actual computation itself. Since the interactive prompt prints things out
without the user explicitly asking for it, it's not enough simply to have two
functions available.

numarray set the default to summarize, and numpy kept numarray's choice.
I 100% approve of the summarization by default. It has saved me *many* times.

Dave
Dec 4 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Stephen | last post by:
I have two arrays: int array1 = { { 1, 2, 3 }, { 4, 5, 6 } }; int array2 = { { 1, 2 }, { 3 }, { 4, 5, 6 } }; I need to print both of them by column like this:
4
by: Shailesh | last post by:
Hi! I want to overload << operator so that it can print an arry defined in MyClass.My problem is that I want to print only a no of elements NOT all the elements in the array and this no of...
5
by: Krish | last post by:
Hello People I hope I am On Topic. Anyways, here is my problem. Any insights would be really appreciated. I have wrapped a C IO module using SWIG -> Python Module. Suppose the name of the...
7
by: dmitrey | last post by:
howto make Python list from numpy.array? Thx, D.
2
by: David Sanders | last post by:
Hi, I have a script with function definitions which I load into ipython for interactive use. These functions modify a global numpy array, whose size I need to be able to change interactively. ...
4
by: jimgardener | last post by:
hi, (i posted this to numpy discussion grp couple of days back ..but it fails to appear..)since it is needed for my work i would appreciate if anyone can help me with this question i have two...
2
by: Rick Giuly | last post by:
Hello All, Case 1 This generates an error, which makes sense because the argument should be a list of numbers: numpy.array(10,10) Case 2 This does not generate an error and the result is an...
3
by: Rüdiger Werner | last post by:
Hello! Out of curiosity and to learn a little bit about the numpy package i've tryed to implement a vectorised version of the 'Sieve of Zakiya'. While the code itself works fine it is...
3
by: Slaunger | last post by:
I know there must be a simple method to do this. I have implemented this function for calculating a checksum based on a ones complement addition: def complement_ones_checksum(ints): """...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.