Hi Travis and team,
I am just writing some docs for subclassing, and ran into some
behavior I didn't understand:
In [143]: class A(np.ndarray): pass
In [144]: arr = np.arange(5)
In [145]: obj = arr.copy().view(A)
In [146]: type(obj)
Out[146]: class '__main__.A'
In [147]:
Hi ,
I'm just surprised by the behaviour of numpy.asarray on lists.
Can someone comment this :
=
a=(1)
aa=asarray(a)
print aa.size , aa.shape
1 ( )
=
The shape doesnot reflect the actual size.
If a=(1,2) there is no problem .
=
Claude Gouedard wrote:
Hi ,
I'm just surprised by the behaviour of numpy.asarray on lists.
Can someone comment this :
=
a=(1)
aa=asarray(a)
print aa.size , aa.shape
1 ( )
=
The shape doesnot reflect the actual size.
Because a is not a
Manuel Metz wrote:
Claude Gouedard wrote:
Hi ,
I'm just surprised by the behaviour of numpy.asarray on lists.
Can someone comment this :
=
a=(1)
aa=asarray(a)
print aa.size , aa.shape
1 ( )
=
The shape doesnot reflect the actual size.
Wed, 27 Aug 2008 16:48:48 +0200, Claude Gouedard wrote:
Hi ,
I'm just surprised by the behaviour of numpy.asarray on lists.
Can someone comment this :
=
a=(1)
aa=asarray(a)
print aa.size , aa.shape
1 ( )
=
() are not list delimiters in
Ok ,
The same for asarray(1) ..
The problem is that
aa=asarray(1) is an numpy.array (right ? ) with a size 1 and a shape ( ) !
No surprising ?
Claude
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
Claude Gouedard wrote:
Ok ,
The same for asarray(1) ..
The problem is that
aa=asarray(1) is an numpy.array (right ? ) with a size 1 and a shape ( ) !
No surprising ?
I think it is considered a 0-dimensional array (= a scalar).
--
Dag Sverre
___
On Wed, Aug 27, 2008 at 12:01 PM, Claude Gouedard [EMAIL PROTECTED] wrote:
Ok ,
The same for asarray(1) ..
The problem is that
aa=asarray(1) is an numpy.array (right ? ) with a size 1 and a shape ( ) !
No surprising ?
For me, this is not surprising at all :-) . Furthermore, if you try
In
bit of a newb question, is there a method for normalising a 1D vector
so it ends up with magnitude 1?
I can do it manually but I was hoping there was a neat numpy - or
scipy - trick. I've been web surfing but nothing really leaps out
___
I don't know what you mean by a 1D vector, but for a 3-vector, you can
do this (also works for N-dimensions)
In [1]: a=r_[1.,2.,3.]
In [2]: a
Out[2]: array([ 1., 2., 3.])
In [3]: b=a/norm(a)
In [4]: b
Out[4]: array([ 0.26726124, 0.53452248, 0.80178373])
Gary R
bit of a newb question, is
sorry, 1D array
this is perfect, thanks.
On Aug 27, 10:18 pm, Gary Ruben [EMAIL PROTECTED] wrote:
I don't know what you mean by a 1D vector, but for a 3-vector, you can
do this (also works for N-dimensions)
In [1]: a=r_[1.,2.,3.]
In [2]: a
Out[2]: array([ 1., 2., 3.])
In [3]:
Hey Matthew
2008/8/27 Matthew Brett [EMAIL PROTECTED]:
In [148]: type(np.multiply(arr, obj)) # this is what I expected
Out[148]: class '__main__.A'
In [149]: type(np.multiply.outer(arr, obj)) # this is not - I expected
class A again
Out[149]: type 'numpy.ndarray'
Since both those objects
Hi Neil
2008/8/26 Neil Crighton [EMAIL PROTECTED]:
- Should we have a separate User manual and a Reference manual, or only
a single manual?
Are there still plans to write a 10 page 'Getting started with NumPy'
document? I think this would be very useful. Ideally a 'getting started'
13 matches
Mail list logo