First a trap for new players, then a question to developers
Code accelerated by numpy can be slowed down by a large factor is you
neglect to import numpy.sum .
from timeit import Timer
frag = 'x=sum(linspace(0,1,1000))'
Timer(frag ,setup='from numpy import linspace').timeit(1000)
# 0.6 sec
Timer(
The example here is for pydb which works as well (and is more like
gdb).
On Oct 23, 12:07 pm, "Diez B. Roggisch" wrote:
> bdb112 wrote:
> > After a while programming in python, I still don't know how to break
> > out to the debugger other than inserting an instruction t
After a while programming in python, I still don't know how to break
out to the debugger other than inserting an instruction to cause an
exception.
x=1/0
In IDL one woudl write
stop,'reason for stopping...'
at which point you can inspect locals (as in pdb) and continue (but
you can't with pdb if
After a while programming in python, I still don't know how to break
out to the debugger other than inserting an instruction to cause an
exception.
x=1/0
In IDL one woudl write
stop,'reason for stopping...'
at which point you can inspect locals (as in pdb) and continue (but
you can't with pdb if
Summary:
It is not straightforward to avoid memory leaks/consumption in pylab.
If we define
x = arange(1e6) # adjust size to make the increment visible, yet
fast enough to plot
# then repetition of
plot(x,hold=0) # consumes increasing memory according to ubuntu
system monitor
Details:
#vers
On Jul 21, 2:13 pm, Ben Finney wrote:
> bdb112 writes:
> > If I want to add an element at the beginning of an array, it seems
> > like I must make a list, insert in place, then make an array again.
>
> The NumPy ‘ndarray’ type (which is what you get by default from the
>
If I want to add an element at the beginning of an array, it seems
like I must make a list, insert in place, then make an array again.
Of course, lists can be efficient too, and the insert() funtion works
nicely in that case, but sometimes arrays are the best choice
e.g.
x=array([1,2,3])
# to put
THanks Gabriel,
Now I know about the zip function.
Your explanation of Boolean ops on lists was clear.
It leads to some intriguing results:
bool([False])
--> True
I wonder if python 3 changes any of this?
> A and B means: check the boolean value of A; if it's false, return A.
> Else, return B
Is there any obvious reason why
[False,True] and [True,True]
gives [True, True]
Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
(Intel)]
--
http://mail.python.org/mailman/listinfo/python-list
one. (+).
On Mar 16, 5:00 pm, bdb112 wrote:
> # is the difference between
> print(" %d, %d, buckle my shoe" % (1,2))
> # and
> print(" %d, " + " %d, buckle my shoe" % (1,2))
> # a bug or a feature?
>
> First output
> ... print(" %d &quo
#whoops, the first output is actually
1, 2, buckle my shoe
# in case it wasn't obvious
On Mar 16, 5:00 pm, bdb112 wrote:
> # is the difference between
> print(" %d, %d, buckle my shoe" % (1,2))
> # and
> print(" %d, " + " %d, buckle my shoe&q
# is the difference between
print(" %d, %d, buckle my shoe" % (1,2))
# and
print(" %d, " + " %d, buckle my shoe" % (1,2))
# a bug or a feature?
First output
... print(" %d " + " %d, buckle my shoe" % (1,2))
Second output
TypeError: not all arguments converted during string formatting
Versio
thon25/python.exe "C:\Python25\scripts\ipython" -pylab $*
(Same problem if I use the windows Start menu Ipython IPython and
pysh)
On Mar 11, 7:34 am, bdb112 wrote:
> Q1/ I run a standard python ditribution with ipython and readline
> under cygwin. The tab filename completion w
Q1/ I run a standard python ditribution with ipython and readline
under cygwin. The tab filename completion works fine in the OS (bash
shell) as expected, and tab filename completion at the ipython command
line works, but with MS style path separators (backslash: run examples
\test.py) which the r
t("ClusterSet.plot body")
plot.__doc__ += "extra" + Cluster.plot.__doc__
cs=ClusterSet()
print(cs.__doc__)
print(cs.plot.__doc__)
On Mar 10, 7:30 am, Chris Rebert wrote:
> On Mon, Mar 9, 2009 at 3:23 PM, bdb112 wrote:
> > A function of the class ClusterSet uses
A function of the class ClusterSet uses a similar function of the
class Cluster to do most of its work. Its docstring could have so
much in common with that in Cluster that it could be just a line or
two in addition to that of Cluster.
Is there a way for the ClusterSet docstring to tack the Clust
16 matches
Mail list logo