Tom K. | 4 Jul 15:28

Access to IPython's timeit result


Hi, 
 Looking at timeit in IPython, you get a nice output e.g.

In [14]: timeit x=range(100000)
100 loops, best of 3: 5.75 ms per loop

but what if I want to get access to that 5.75 ms number so I can write a
program to capture these over a list of "N" values and make a plot of time
versus "N"?

 - Tom K.
--

-- 
View this message in context: http://www.nabble.com/Access-to-IPython%27s-timeit-result-tp24334619p24334619.html
Sent from the Scipy-User mailing list archive at Nabble.com.
Craig Finch | 3 Jul 04:50
Favicon

Scipy weave errors: undefined symbols when importing compiled extension


I have two computers that have almost identical Python installations,
but one of them has problems with inline Weave code.  Here is a simple
test script that I am using:

#!/usr/bin/env python
from scipy import weave
input_val = 10

code=r"""return_val = 10*input_val;"""

print weave.inline(code, ['input_val'], headers=[], compiler='gcc')

It runs successfully on one computer with the following configuration:
Python 2.5.2 (r252:60911, Apr 17 2009, 18:42:17) 
[GCC 4.1.1 (Gentoo 4.1.1-r3)] on linux2
Scipy 0.7.0
Numpy 1.3.0

On the other computer, it fails with the following message:
Traceback (most recent call last):
  File "test.py", line 12, in <module>
    print weave.inline(code, ['input_val'], headers=[], compiler='gcc')
  File "/home/cfinch/lib/python2.5/site-packages/scipy/weave/inline_tools.py", line 335, in inline
    **kw)
  File "/home/cfinch/lib/python2.5/site-packages/scipy/weave/inline_tools.py", line 468, in compile_function
    exec 'import ' + module_name
  File "<string>", line 1, in <module>
ImportError: /home/cfinch/.python25_compiled/sc_71b2502f9a0b0ca9f89b0cdc7ad3819e0.so:
undefined symbol: _ZNSt8ios_base4InitD1Ev
(Continue reading)

Dharhas Pothina | 2 Jul 17:57
Favicon

Add a column to masked array.

Hi,

I have a masked array 'data' where data.shape = (1805,4) and another masked array 'a' where a.shape =
(1805,) 

I would like to generate a new masked array with the 'a' as the last column , i.e. the final shape should be
(1805,5). 

I've tried np.hstack which gave an error 'arrays must have same number of dimensions' and ma.hstack just
combines both masked arrays into a list.

how would I go about doing what I need?

thanks

- dharhas
Lorenzo Isella | 2 Jul 15:24

Creating a Matrix from a Sum

Dear All,
I need some help to efficiently write an array manipulation. I suspect 
this could be a one-liner.
Assume that you have a histogram of observations that you store in a 
vector x.
Let us say that its i-th entry, x_i, corresponds to the number of 
observations in the i-th channel, for i=1,2...N. (or 0,1...N-1, please 
let me know if there is any potential 0/1 pitfall in the following).
Now, for any two channels i and j, I want to calculate the probability 
of having an observation  in any other channel k, where  k>=max(i,j).
That is to say

P(i,j)=sum_{k=max(i,j)}^N x_k /C,
where C=sum_{i=1}^N x_i is just a normalization factor.

Does anyone know a good way of writing this in a code to get the P(i,j) 
matrix?
Many thanks

Lorenzo
alan | 30 Jun 03:31
Favicon

Paper in Science

Anne,

Is that your paper in the June 12 issue of Science?

Alan

--

-- 
-----------------------------------------------------------------------
| 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       |
-----------------------------------------------------------------------
Christian Bähnisch | 29 Jun 10:06

scipy.linalg.inv returns array

Hello, 

I noticed that "scipy.linalg.inv" returns the inverse of a matrix as an array 
not as a matrix. I think returning a matrix would be more convenient, or 
missed I something?

greetings, Chris 
Jarrod Millman | 29 Jun 08:58
Favicon

ANN: SciPy 2009 student sponsorship

I am pleased to announce that the Python Software Foundation is
sponsoring 10 students' travel, registration, and accommodation for
the SciPy 2009 conference (Aug. 18-23).  The focus of the conference
is both on scientific libraries and tools developed with Python and on
scientific or engineering achievements using Python.  If you're in
college or a graduate program, please check out the details here:
http://conference.scipy.org/student-funding

About the conference
--------------------

SciPy 2009, the 8th Python in Science conference, will be held from
August 18-23, 2009 at Caltech in Pasadena, CA, USA.  The conference
starts with two days of tutorials to the scientific Python tools.
There will be two tracks, one for introduction of the basic tools to
beginners, and one for more advanced tools.  The tutorials will be
followed by two days of talks.  Both days of talks will begin with a
keynote address.  The first day’s keynote will be given by Peter
Norvig, the Director of Research at Google; while, the second keynote
will be delivered by Jon Guyer, a Materials Scientist in the
Thermodynamics and Kinetics Group at NIST.  The program committee will
select the remaining talks from submissions to our call for papers.
All selected talks will be included in our conference proceedings
edited by the program committee.  After the talks each day we will
provide several rooms for impromptu birds of a feather discussions.
Finally, the last two days of the conference will be used for a number
of coding sprints on the major software projects in our community.

For the 8th consecutive year, the conference will bring together the
developers and users of the open source software stack for scientific
(Continue reading)

alan | 29 Jun 05:03
Favicon

small bug in random.noncentral_f

(pardon me if this shows up twice. I seem to be having list issues)

Currently working on documenting various functions, and I think I found
a buglet with the random.noncentral_f function.

Parameters are dfnum, dfden, and nonc, for the two degrees of freedom
and the non=centrality.  If noncentrality is zero, then this should
reduce to simply an F statistic. But when I tested the function, it
does not allow a dfnum = 1, while random.f does.

In [15]: np.random.f(1., 48, 10)
Out[15]: 
array([ 0.00858266,  0.03674191,  0.01160252,  0.00440044,  0.00113941,
        0.00145305,  0.07257887,  0.01387694,  0.08171868,  0.00591559])
In [16]: np.random.noncentral_f(1., 48, 0, 10)
ValueError: dfnum <= 1

Interestingly I tried the equivalent function in R, and it even works
for dfnum<1, though I'm not clear on what that means.

> rf(10, .9, 48, 0)  
 [1] 0.005920147 0.246702423 0.213558149 0.328364697 4.157683259
0.048531606 [7] 0.463760833 6.817103616 0.058326258 0.813737713

--

-- 
-----------------------------------------------------------------------
| 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       |
(Continue reading)

Ala Al-Shaibani | 28 Jun 20:40

error after using odeint (excess work done + lsoda)

I used odeint to solve a coupled ode, and then printed the solution. The solution is correct, but I'm wondering as to why I'm receiving the error before printing the solution, and the lsoda error after printing the solution (although all I do is print the solution).


Would appreciate any help.





Excess work done on this call (perhaps wrong Dfun type).

Run with full_output = 1 to get quantitative information.

 [ 13.9  20.7  79.8  14.6  78.8]

 lsoda--  at current t (=r1), mxstep (=i1) steps   

       taken on this call before reaching tout     

      In above message,  I1 =       500

      In above message,  R1 =  0.3409980342206E+01



_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user
Emmanuelle Gouillart | 28 Jun 00:02
Favicon

nunmpy.lookfor and scipy submodules

	Hi list,

	while working on a course about scientific computing with Python,
I found myself playing with numpy.lookfor. To my surprise, I found that
the submodules of scipy are never searched by numpy.lookfor (see example
below). Apparently, this comes from the fact that the submodules are not
in scipy.__all__. I'm sure this is a very naive question, but why is it
so ? It can be quite confusing for people looking for documentation when
they don't find any match for 'optimize' in scipy... I'm using numpy
1.2.1 and scipy 0.7.

	Thanks in advance,

	Emmanuelle 

Example:

>>> np.lookfor('optimize', module=scipy, import_modules=True)
Search results for 'optimize'
-----------------------------
>>> np.lookfor('interpol', module=scipy, import_modules=True)
Search results for 'interpol'
-----------------------------
scipy.interp
    One-dimensional linear interpolation.
scipy.misc.imrotate
    Rotate an image counter-clockwise by angle degrees.
scipy.sinc
    Return the sinc function.
scipy.polyfit
    Least squares polynomial fit.
scipy.bartlett
    Return the Bartlett window.
scipy.ma.polyfit
    Least squares polynomial fit.
>>> # nothing from scipy.interpolate !!
>>> np.lookfor('filename', os)
Search results for 'filename'
-----------------------------
os.open
    Open a file (for low level IO).
os.mknod
    Create a filesystem node (file, device special file or named pipe)
os.mkfifo
    Create a FIFO (a POSIX named pipe).
os.path.realpath
    Return the canonical path of the specified filename, eliminating any
os.walk
    Directory tree generator.
os.path.walk
    Directory tree walk with callback function.
>>> # With os, submodules are also searched
Dr. Johannes Zellner | 27 Jun 22:03

2d interpolation -- comparison of different methods

Hi,

I'd like to do 2d interpolation on f(x, y) scattered input data (no
order, no regular grid).
The interpolation should go through the original data values.

I'm confused about different methods I found, e.g.

SmoothBivariateSpline, RectBivariateSpline, BivariateSpline, griddata,
interp2, bisplrep / bisplev, Rbf

1. Does anyone have a comparison between these (and maybe more)?

2. Which of these are appropriate to do the interpolation I've written above?

Any help much appreciated.

--
Johannes Zellner <johannes <at> zellner.org>

Gmane