On Wednesday, July 10, 2013 4:00:59 PM UTC+2, Chris Angelico wrote:
[...]
> So, a few questions. Firstly, is there a stdlib way to find the key
> with the lowest corresponding value? In the above map, it would return
> 3, because 18 is the lowest value in the list. I want to do this with
> a single
On Wednesday, July 10, 2013 5:12:19 PM UTC+2, Chris Angelico wrote:
> Well, that does answer the question. Unfortunately the use of lambda
> there has a severe performance cost [ ...]
If you care about speed, you might want to check the heapq module. Removing the
smallest item and inserting a new
sible for the current code? I didn't play a lot
with python yet, so I probably missed some typical python tricks, like
converting for-loops to list expressions.
TIA,
Bas
***
from itertools import ifilterfalse
problem1 = [' 63 7 ',
' 69 8
>> def all(seq, pred=bool):
>What's this? What is bool?
That came straight out of the manual for itertools:
http://docs.python.org/lib/itertools-recipes.html
--
http://mail.python.org/mailman/listinfo/python-list
he result.
Are there any advantages for using one method over the other? Note that I have
more experience with python than with C.
Thanks,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
ple, something similar is probably happening, since you assign
something to third inside example2, thereby making it 'local'. Since you are
dealing with classes, the error message is probably not so clear (but whywhywhy
would you define a class inside a function?) Does that make sense?
):
print a,b,c
0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
Cheers,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
the best of both worlds. For future work you should stick
to SciPy. Right now it is probably somewhere in a beta stage, but
expect a final version in half a year or so. Hopefully it ends up being
THE vector lib for python to avoid confusing beginners like you.
Cheers,
Bas
--
http://mail.python.org
Read this first:
http://www.catb.org/~esr/faqs/smart-questions.html
and then try again.
--
http://mail.python.org/mailman/listinfo/python-list
ly try the example
by typing it over himself or by clicking a button 'run in console' next
to the example. Target audience should be only the real beginners who
are afraid/too lazy to install the complete Python enviroment. Advanced
users should be able to do a full install themselves.
C
There is more in this thread:
http://groups.google.com/group/comp.lang.python/browse_frm/thread/479c1dc768f740a3/9252dab14e8ecabb?q=sudoku&rnum=2#9252dab14e8ecabb
Enjoy,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
I like the use of the colon as in the PEP better: it is consistant with
the slice notation and also with the colon operator in Matlab.
I like the general idea and I would probably use it a lot if available,
but the functionality is already there with range and irange.
Bas
--
http
I think you need one of these:
http://www-03.ibm.com/servers/deepcomputing/bluegene.html
Don't know if it runs python. If that doesn't work try to reformulate
your problem and have a look at
http://scipy.org/
Cheers,
Bas
[EMAIL PROTECTED] wrote:
> I want to write a program which
Are there any differences between this module and the one already
present in numpy?
http://www.scipy.org/doc/numpy_api_docs/numpy.lib.polynomial.html
Cheers,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
You are comparing a normal python list to a constant, which are
obviously unequal. Try converting your lists to arrays first
(untested):
import numeric/numpy as N
a =N.array([0,1,2,5,6,6])
b = N.array([5,4,1,6,4,6])
print a==6 and b==6
print N.where(a==6 and b==6)
hth,
Bas
Sheldon wrote:
>
overkill for your simple problem, but this is a nice
alternative if you do a lot of matrix work.
Bas
--
http://mail.python.org/mailman/listinfo/python-list
=a>5;
a(cond) = 6;
or even shorter
a(a>5) = 6;
Does someone know if the same trick is possible in NumPy?
Cheers,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
I believe it is something like
a[a==0] = 5
Note that numarray will eventually be replaced by Scipy/Numpy at some
time, but this wouldn't change the basic stuff.
Cheers,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
in x:
y=dot(xx,w)
y2 = y*y
w+=ETA*(y*xx-y2*w);
th+= INV_TAU*(y2-th);
Hope it helps,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
Try this, don't know if this works for al versions:
from pylab import *
x=10**linspace(0,5,100)
y=1/(1+x/1000)
loglog(x,y)
show()
If you only need a logarithm along one axis you can use semilogx() or
semilogy(). For more detailed questions go to the matplotlib mailing
list.
Cheers
lice(10,20)'. The only difference is see is some behavior
with infinities (e.g. object[3:] gives a slice(3,maxint) inside
_getitem_ , but I think this should not be a large problem
(xrange(0,infinity) could just yield a generator that never stops).
Which problems am I overlooking that prevent thi
n achieve the frequency modulation by using phase modulation
(these two are related). You can do this with your own code by
phi = oscillator(t, freq=6, amp=15/6)
tone = oscillator(t, freq=1000, amp=0.1, phase=phi)
cheers,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
inite loop!
Bas
--
http://mail.python.org/mailman/listinfo/python-list
unless you are dealing with life-
critical equipment or are using extreme programming, this is overkill
(but I guess python is not really the right language for that anyway,
imagine a garbage collection just when you want to launch your
shuttle).
Bas
--
http://mail.python.org/mailman/listinfo/python-list
On Oct 21, 5:43 pm, azrael <[EMAIL PROTECTED]> wrote:
> Need some advice
I advice to come up with a more specific subject line for your posts,
might give you some more answers
--
http://mail.python.org/mailman/listinfo/python-list
ct)
plot(x,polyval(poly1,x),x,polyval(poly2,x),x_intersect,y_intersect,'o')
show()
HTH,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
ad of addition.
Make sure that you understand the difference between generator
expression and list comprehension, and that [f(x) for x in something]
is (almost) equal to list(f(x) for x in something), so you can emulate
a LC by using the list constructor on the equivalent GE.
HTH,
Bas
--
http:
ity, I
think your time and skills are better spent writing some cool
mechanical analysis tool for inclusion in Scipy.
Bas
--
http://mail.python.org/mailman/listinfo/python-list
I only have experience with the matlab version of polar, but my wild
guess is that you have convert your degrees to radians. Go to the
Matplotlib newsgroup if you need any better help.
HTH,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
use list-comprehensions, that is the whole idea about using
these kick-ass objects!
Bas
--
http://mail.python.org/mailman/listinfo/python-list
might not be totally correct):
x[i] -> x.__getitem__(i)
x[a:b] -> x.__getitem__(slice(a,b,None))
x+y -> x._add__(y)
x.method(a) -> call (x.__dict__[method], self, a) ??
for i in x: f(i) -> it = iter(x); while True: i = it.next(); f(i)
except stop: pass
TIA,
Bas
--
http://mai
>That kind of depends on what you mean by syntactic sugar.
Mightbe I was misusing the name of syntactic sugar, but I what I
intended to say was "all the possible 'transformations' that can be
made to reduce all the 'advanced' syntax to some sort of minimal core
of t
179, 174, 175, 176, 177, 178, 179]))
177.0
If the deg2rad and rad2deg bothers you, you should write your own
unwrap function that handles data in degrees.
Hope this helps,
Bas
P.S.
Slightly off-topic rant against both numpy and matlab implementation
of unwrap: They always assume data is in radian
> On 2010-01-25 10:16 AM, Bas wrote:
>
> > P.S.
> > Slightly off-topic rant against both numpy and matlab implementation
> > of unwrap: They always assume data is in radians. There is some option
> > to specify the maximum jump size in radians, but to me it would be
> >> On 2010-01-25 10:16 AM, Bas wrote:
> >>> P.S.
> >>> Slightly off-topic rant against both numpy and matlab implementation
> >>> of unwrap: They always assume data is in radians. There is some option
> >>> to specify the maximum jump si
maybe a terminal length issue,
> I don't know), breaking my parsing.
Below is the script I use to automatically kill firefox if it is not
behaving, maybe you are looking for something similar.
HTH,
Bas
#!/usr/bin/env python
import commands, os
lines = os.popen('ps ax|grep firefox&
numbers for the imperially
challenged people:
In [1]: import scipy.constants as c
In [2]: def acre2sqft(a):
...: return a * c.acre / (c.foot * c.foot)
...:
In [3]: acre2sqft(1)
Out[3]: 43560.0
Cheers,
Bas
--
http://mail.python.org/mailman/listinfo/python-list
truct will finally start to look good.
Using IFs is just plain ugly. Why not go for the much more pythonic
code = (lambda s:dir[slice(*(s*int(num),None)[::s])])(cmp('o',side))
Much easier on the eyes and no code duplication ... ;)
Bas
--
http://mail.python.org/mailman/listinfo/python-list
t() on the object's
attributes using the __class__ 's to construct
generic names for the instantiations.
Has anyone given this a thought already ?
Thank you in advance for any remarks,
--
Bas Michielsen
ONERA, Electromagnetics and Radar Department
2, avenue Edouard Belin, 31055 TOULOUS
Jerome Alet wrote:
> Hi,
>
> Le Fri, 08 Jul 2005 15:16:21 +0200, Bas Michielsen a écrit :
>
>
>>Is there a good/standard way of having (composite)
>>objects write a Python script which will regenerate
>>the very same object ?
>
>
> I've don
On Jan 30, 7:34 am, Pom <[EMAIL PROTECTED]> wrote:
> how can I emulate a serial port in windows?
Google for ComEmulDrv3
This may do what you want.
--
http://mail.python.org/mailman/listinfo/python-list
istance.c"
in the edit_distance.i file.
Then I changed the first few lines of your function definition
unsigned int edit_distance( const char* c1, const char* c2 )
{
std::string s1( c1), s2( c2);
and also adapted the signature in the edit_distance.i file.
Then
swig -shadow -c++ -python
--
import _bsddb
--
I had a look around through /usr/lib/python2.4 but I couldn't find a _bsddb
indeed. Can anyone help me get my favorite py-tool to work again ;-)?
Bas
--
<[EMAIL PROTECTED]> - GPG Key ID: 2768A493 - http://www.cs.ru
On 2005-03-03, Bas van Gils <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I've been using the `pytone' tool for playing my mp3's for a while. Great
> tool. However, after upgrading Python to version 2.4 it stopped working. The
> traceback that I get is this:
[
Using the enum34 0.9.13 package from PyPi in Python 2.7.3, the examples
for OrderedEnum seem to be broken.
The example in the package documentation reads:
class OrderedEnum(Enum):
def __ge__(self, other):
if self.__class__ is other.__class__:
return self._value >= other.
On 30-7-2013 21:30, Ethan Furman wrote:
On 07/30/2013 11:58 AM, Ian Kelly wrote:
On Tue, Jul 30, 2013 at 12:18 PM, Bas van der Wulp
wrote:
Replacing each occurrence of self._value with either self._value_ or
self.value in the examples seems to make them work as expected.
Are both examples
46 matches
Mail list logo