[Numpy-discussion] Distance Formula on an Array

Eric Firing efiring@hawaii....
Sun Apr 26 17:48:53 CDT 2009

Ian Mallett wrote:
> Yeah, I ended up finding the [0] bit at the end through trial and 
> error.  I actually do need the indices, though.

If you are not already doing so, I strongly recommend using ipython.  It 
  is enormously useful in accessing docstrings (type a function name 
followed by a question mark), source code (same, but with two question 
marks), listing namespaces, finding functions, testing, running the pdb 
debugger, etc.

> I'm having a strange new problem though.
> numpy.array([1,2,3])
> is returning a sequence???  I'm really confused. 

In ipython:

In [1]:import numpy as np

In [2]:x = np.array([1,2,3])

In [3]:type(x)
Out[3]:<type 'numpy.ndarray'>

In [4]:x
Out[4]:array([1, 2, 3])

The term "sequence" is a generality to include tuples, lists, ndarrays, 
and potentially other such ordered containers.

But where are you seeing the ndarray instance created by numpy.array() 
referred to as a "sequence"?  It's not wrong, but I can see why you 
might not expect it.


More information about the Numpy-discussion mailing list