Pauli Virtanen | 4 Jul 14:58
Favicon

Adding new functions to Numpy

Hi,

When you add new functions to Numpy, please include

    .. versionadded:: 1.4.0

in the Notes section of the function's docstring, and add the 
functions to an appropriate section of the reference guide. Like 
this:

    http://projects.scipy.org/numpy/changeset/7107

This way, users can keep track of which features are supported in 
which version.

--

-- 
Pauli Virtanen
Dan Yamins | 4 Jul 04:40

__eq__ method for recarray returns recarray

If I have two recarrays with the same len and column headers, the __eq__ method returns the rich comparison, which is great.  E.g.

In [20]: x = np.rec.fromrecords([(1,2,'dd',.3),(33,2,'y',2.2),(2,3,'a',21.4),(3,4,'b',33.2)],names=['A','B','C','D'])

In [21]: y = np.rec.fromrecords([(1,2,'dd',.3),(33,2,'y',2.2),(2,3,'a',21.4),(3,4,'b',33.2)],names=['A','B','C','D'])

In [22]: x == y
Out[22]: rec.array([ True,  True,  True,  True], dtype=bool)


But notice that the returned object is a recarray, not an array of bools.   Why is this, and what is the purpose of having it this way?

Similarly, if I subclass recarray, and say, in my subclass attach some attributes to x, then these attributes are attached to the result of the rich comparison.  E.g. suppose I have a subclass of recarray called "NewRecarray" to which I attach an attribute .info.  Then

x = NewRecarray(data)
y = NewRecarray(data)
z = x == y

Then z is a NewRecarray object and z.info = x.info.

Is this the expected / proper behavior?  Is there something wrong with the way I've subclassed recarray?


Thanks,
Dan



_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Alan Jackson | 4 Jul 01:36
Favicon

Bug in the F distribution?

I either found a bug in the F distribution, or I'm really messed up.

>From a table I find

dfnum  dfden  F(P<.01)
10      10     4.85
11      10     4.78
11      11     4.46
10      11     4.54

So let's calculate the same quantities using numpy...

import scipy.stats as stats
import numpy as np
In [89]: stats.scoreatpercentile(np.random.f(10,10,1000000), 99)
Out[89]: 4.8575912131878365
In [90]: stats.scoreatpercentile(np.random.f(11,10,1000000), 99)
Out[90]: 5.2721528315236501
In [91]: stats.scoreatpercentile(np.random.f(11,11,1000000), 99)
Out[91]: 4.4695161332631841
In [92]: stats.scoreatpercentile(np.random.f(10,11,1000000), 99)
Out[92]: 4.1229323443042674

So at 10,10 and 11,11 it works (maybe), but all the other values are clearly
off. I tried re-running the example I put into the documentation last summer,
which worked, and I don't get the right answer any longer. 

--

-- 
-----------------------------------------------------------------------
| Alan K. Jackson            | To see a World in a Grain of Sand      |
| alan <at> ajackson.org          | And a Heaven in a Wild Flower,         |
| www.ajackson.org           | Hold Infinity in the palm of your hand |
| Houston, Texas             | And Eternity in an hour. - Blake       |
-----------------------------------------------------------------------
Fabrice Silva | 3 Jul 11:44
Favicon

roots and high-order polynomial

Hello
Has anyone looked at the behaviour of the (polynomial) roots function
for high-order polynomials ? I have an application which internally
searches for the roots of a polynomial. It works nicely for order less
than 20, and then has an erratic behaviour for upper values...

I looked into the source and I wondered that roots is based on the
eigenvalues of the companion matrix. For high-order, this latter is
rather sparse. Would it improve anything to compute the eigenvalues
using sparse solvers?

--

-- 
Fabrice Silva
Laboratory of Mechanics and Acoustics - CNRS
31 chemin Joseph Aiguier, 13402 Marseille, France.
Sebastian Haase | 3 Jul 11:14

argwhere does not accept py list

Hi,
should this not be accepted:
>>> N.argwhere([4,0,2,1,3])
?
instead I get

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "./numpy/core/numeric.py", line 510, in argwhere
AttributeError: 'list' object has no attribute 'nonzero'
>>> N.argwhere(N.array([4,0,2,1,3]))
[[0]
 [2]
 [3]
 [4]]
>>> N.__version__
'1.3.0'
>>>

Just a note.
-Sebastian Haase
Peter Kelley | 3 Jul 00:42

Using loadtxt to read in mixed data types


Hey Everyone,

I am reading in a file of columns with mixed data types, and the number of columns can vary and their format is inputted by the user. So I came up with this:

dt=dtype({'names': [x for x in event_fields], 'formats': [b for b in event_format]})

eventArray = loadtxt(behEventFile,dt)

where event_format is ['long', 'int', 'int', 'int', 'int', 'int', 'str', 'str', 'int', 'int', 'int', 'int', 'int', 'int', 'int', 'int']

I get TypeError: data type not understood, and I think it is because the event format is a list of strings not data types. Does anyone have know how to convert the list of strings into the data types for dtype.

-Peter

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Sebastien Binet | 2 Jul 10:08

pep-3118 extended struct format parser

hi there,

at last scipy'08 sprint, somebody (apologies for my brain fade) was working on 
being able to parse the extended struct format string so one could do:

Nested structure
    ::

        struct {
             int ival;
             struct {
                 unsigned short sval;
                 unsigned char bval;
                 unsigned char cval;
             } sub;
        }
        """i:ival: 
           T{
              H:sval: 
              B:bval: 
              B:cval:
            }:sub:
        """
Nested array
    ::

        struct {
             int ival;
             double data[16*4];
        }
        """i:ival: 
           (16,4)d:data:
        """

is this available somewhere ?
(being it in pure python or fast-C implemented, I don't really care for the 
moment :) )

cheers,
sebastien.
--

-- 
#########################################
# Dr. Sebastien Binet
# Laboratoire de l'Accelerateur Lineaire
# Universite Paris-Sud XI
# Batiment 200
# 91898 Orsay
#########################################
Elaine Angelino | 2 Jul 03:01

ndarray from column data

Hi there --

Is there a fast way to make a numpy ndarray from column data? 

For example, suppose I want to make an ndarray with 2 rows and 3 columns of different data types based on the following column data:

C0 = [1,2]
C1 = ['a','b']
C2 = [3.3,4.4]

I could create an empty ndarray and fill the columns one by one:

X = numpy.core.ndarray((2,), dtype='<i4,|S1,<f8')
X['f0'] = C0
X['f1'] = C1
X['f2'] = C2

The result is the same as:

X = numpy.array([(1,'a',3.3), (2,'b',4.4)], dtype='<i4,|S1,<f8')

but I would like to make X directly from the column data.

[  I know that numpy.core.records.fromarrays will produce a numpy recarray from column data, but this of course is a recarray and not a ndarray! For ex:

X = numpy.numpy.core.records.fromarrays([C0,C1,C2])  ]

Thanks for any help,

Elaine

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion <at> scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
Nils Wagner | 1 Jul 20:33

make html

Hi all,

I am using

>>> numpy.__version__
'1.4.0.dev7094'

make html yields

/home/nwagner/svn/numpy/doc/source/reference/generated/numpy.trunc.rst:: 
WARNING: document isn't included in any toctree
done
preparing documents... done
Exception occurred:  2%] reference/generalized_ufuncs 
   ures
   File

"/home/nwagner/local/lib64/python2.6/site-packages/Sphinx-0.6.1-py2.6.egg/sphinx/environment.py", 
line 921, in get_toc_for
     toc = self.tocs[docname].deepcopy()
KeyError: 'reference/generalized_ufuncs'
The full traceback has been saved in 
/tmp/sphinx-err-wlA8vA.log, if you want to report the 
issue to the author.
Please also report this if it was a user error, so that a 
better error message can be provided next time.
Send reports to sphinx-dev <at> googlegroups.com. Thanks!
make: *** [html] Fehler 1

Nils
Mag Gam | 1 Jul 13:56

Multi thread loading data

Is it possible to use loadtxt in a mult thread way? Basically, I want
to process a very large CSV file (100+ million records) and instead of
loading thousand elements into a buffer process and then load another
1 thousand elements and process and so on...

I was wondering if there is a technique where I can use multiple
processors to do this faster.

TIA
David Cournapeau | 1 Jul 09:57

Numpy complex types, packing and C99

Hi,

    I would like to add an explicit configuration test to check that our
complex type is compatible with the C99 complex type (when available).
Is this ok ?

    As currently defined, complex c types (npy_cfloat, etc...) are not
defined in a way such as they are binary compatible with the C99 complex
type. Strictly speaking, packing the complex type is an ABI break, but
we already make the assumption in ufunc, so we would have wrong
results/crashes currently if it were not packed, so I believe the check
is harmless by itself. The rationale is that I would like to add support
for complex math in npy_math (cabs, cexp, etc...). As I would like to
use the C99 complex type (when available), this requires that numpy
complex type is ABI compatible with C99 type.

cheers,

David

Gmane