Re: [Numpy-discussion] Default value in documentation
On Tue, 2 Oct 2007, Charles R Harris apparently wrote: > We're avoiding consolidated fields because they behave > badly. ... The main problem with the consolidated fields > is that they are all put together as item lists in > a definition list and moved to the end of the docstring > when it is rendered. There is also little control through > the .css style sheet, they are all bulleted, and some of > the types are missing. Is Ed Loper aware of this complaint? If so, has he indicated an interest (or lack) in addressing this complaint? Consolidated fields are great: it is a shame to do without them. Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
Edson Tadeu wrote: > For now, I solved it using a view with a different type: > > from numpy import * > N = 5 > a=zeros(N,'3f8') > b=a.view() > b.dtype='f8' > b.shape = N,3 Note that this doesn't quite do what you want. I was wrong about the dtype='3f8' syntax: it just gives you a regular float array with the shape changed appropriately (at least in recent version of numpy; if you are getting something different, what version are you using?). In [24]: from numpy import * In [25]: N = 5 In [26]: zeros(N, dtype='3f8') Out[26]: array([[ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.], [ 0., 0., 0.]]) If you want a shape-(N,) record array, you need a different dtype: In [28]: zeros(N, dtype='f8,f8,f8') Out[28]: array([(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)], dtype=[('f0', 'http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
For now, I solved it using a view with a different type: from numpy import * N = 5 a=zeros(N,'3f8') b=a.view() b.dtype='f8' b.shape = N,3 I'll try to put this mechanism in a subclass. Thanks for the answers, Edson On 10/4/07, Stefan van der Walt <[EMAIL PROTECTED]> wrote: > > On Thu, Oct 04, 2007 at 11:47:40AM -0500, Robert Kern wrote: > > Edson Tadeu wrote: > > > > > * Is there any field in the NumPy object where I can keep this > > > information (the shape of the "element"), without creeping it with the > > > dtype='(M,N)f8' representation I explained above? > > > > There isn't. You could make a subclass that tracks this, but you would > have to > > implement it carefully to maintain the information. > > There is an example of how to do that here: > > http://www.scipy.org/Subclasses > > Regards > Stéfan > ___ > Numpy-discussion mailing list > Numpy-discussion@scipy.org > http://projects.scipy.org/mailman/listinfo/numpy-discussion > ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] adopting Python Style Guide for classes
On Thursday 04 October 2007 13:08:08 David M. Cooke wrote: > Alan G Isaac <[EMAIL PROTECTED]> writes: > > To help me understand, might someone offer some examples of > > NumPy names that really should be changed? > > Internal classes, like: > - masked_unary_operation, etc. in numpy/core/ma.py FYI, the new style has been followed in maskedarray (and a couple of recent bugs fixed in the SVN). ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
On Thu, Oct 04, 2007 at 11:47:40AM -0500, Robert Kern wrote: > Edson Tadeu wrote: > > > * Is there any field in the NumPy object where I can keep this > > information (the shape of the "element"), without creeping it with the > > dtype='(M,N)f8' representation I explained above? > > There isn't. You could make a subclass that tracks this, but you would have to > implement it carefully to maintain the information. There is an example of how to do that here: http://www.scipy.org/Subclasses Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] [SciPy-dev] adopting Python Style Guide for classes
Alan G Isaac <[EMAIL PROTECTED]> writes: > To help me understand, might someone offer some examples of > NumPy names that really should be changed? Internal classes, like: - nd_grid, etc. in numpy/lib/index_tricks.py - masked_unary_operation, etc. in numpy/core/ma.py Things we probably wouldn't change: - array-like things, such as numpy.lib.polynomial.poly1d - ufuncs implemented in Python like vectorize - distributions from scipy.stats In numpy, outside of tests, distutils, and f2py, there's actually not that many classes defined in Python (as opposed to C). In scipy, most non-testing classes are already CamelCase (one exception is weave). -- |>|\/|< /--\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |[EMAIL PROTECTED] ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
Edson Tadeu wrote: > * Is there any field in the NumPy object where I can keep this > information (the shape of the "element"), without creeping it with the > dtype='(M,N)f8' representation I explained above? There isn't. You could make a subclass that tracks this, but you would have to implement it carefully to maintain the information. -- 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 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
Alan G Isaac wrote: > On Thu, 4 Oct 2007, Edson Tadeu apparently wrote: >> Is there any field in the NumPy object where I can keep >> this information (the shape of the "element"), without >> creeping it with the dtype='(M,N)f8' >> representation I explained above? > > Perhaps you want a recarray? No, that's what the dtype='3f8' gets him. He gave reasons why he doesn't want that. -- 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 ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
On Thu, 4 Oct 2007, Edson Tadeu apparently wrote: > Is there any field in the NumPy object where I can keep > this information (the shape of the "element"), without > creeping it with the dtype='(M,N)f8' > representation I explained above? Perhaps you want a recarray? Cheers, Alan Isaac ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
[Numpy-discussion] Best representation for array of points, or, how to distinguish a Nx1 array of points from a Nx3 array of scalars
I've found that there are two ways to represent an array of 3D points: # 01: N = 4 a = numpy.zeros((N, 3), dtype='f8') # 02: N = 4 b = numpy.zeros(N, dtype='3f8') The second representation seems "conceptually" better, it is really an 1D array of N elements ( i.e., b.shape == (4,) ), but, "in practice", it is not very useful, because I can't directly add it to scalar, or to another array of points, and I can't multiply it by a transformation matrix. With the first representation, I can use expressions like this: c = (a+1) * numpy.matrix([[1,0,0],[0,0,3],[0,2,0]]) - numpy.array([1, 5.5, 0]) So, I chose the second representation for my application; the problem is that its shape is (N, 3), and I haven't found a way to distinguish it from a Nx3 array of scalars, for example. This distinction is needed, because I must convert it to other array types (from other libraries), I must make proper I/O of the array, etc. Also, my application uses 2D and 3D arrays, and they can be arrays of scalars, of points or of small matrices... so, for example, a 10x7 array of 2x2 matrices of double is represented in numpy as a 10x7x2x2 array of f8 (without the proper information, it could be viewed also as a 10x7x2 array of 2D points or a 10x7x2x2 array of doubles, and I DON'T want this). My question is: * Is there any field in the NumPy object where I can keep this information (the shape of the "element"), without creeping it with the dtype='(M,N)f8' representation I explained above? Thanks, Edson ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion
Re: [Numpy-discussion] Possible bug in numpy.trace()
Hi Donald On Thu, Oct 04, 2007 at 01:48:18AM +, Donald Fredkin wrote: > It appears that something peculiar is going on with the numpy function > trace(). The docs say that trace(A,...) is identical to A.trace(...). > Here is a test: > > A = arange(8).reshape((2,2,2)) > A.trace(0,1,2) > #[Out]# array([ 3, 11]) > # which is correct > trace(A,0,1,2) > #[Out]# array([6, 8]) > #which is wrong > #Since trace() is computed by summing the result of diagonal() Thanks for the report. This is already fixed in the latest version: In [11]: A.trace(0,1,2) Out[11]: array([ 3, 11]) In [12]: N.trace(A,0,1,2) Out[12]: array([ 3, 11]) In [13]: N.__version__ Out[13]: '1.0.4.dev4149' Regards Stéfan ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion