Re: Prime number generator

2013-07-10 Thread Bas
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

Re: Prime number generator

2013-07-10 Thread bas
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

Brute force sudoku cracker

2005-09-16 Thread Bas
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

Re: Brute force sudoku cracker

2005-09-17 Thread Bas
>> 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

real-time monitoring of propriety system: embedding python in C or embedding C in python?

2013-02-05 Thread Bas
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

Re: baffled classes within a function namespace. Evaluation order.

2013-04-25 Thread Bas
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?

Re: Accessing next/prev element while for looping

2005-12-18 Thread Bas
): 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

Re: Vector math library

2005-12-31 Thread Bas
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

Re: important for me!!

2006-01-02 Thread Bas
Read this first: http://www.catb.org/~esr/faqs/smart-questions.html and then try again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Try Python update

2006-01-04 Thread Bas
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

Re: Sudoku solver: reduction + brute force

2006-01-14 Thread Bas
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

Re: Arithmetic sequences in Python

2006-01-16 Thread Bas
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

Re: Math package

2006-07-29 Thread Bas
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

Re: ratfun-2.3 Polynomials and Rational Functions

2006-08-19 Thread Bas
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

Re: comparing two arrays

2006-06-19 Thread Bas
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: >

Re: returning index of minimum in a list of lists

2006-06-21 Thread Bas
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

Re: Numeric and matlab

2006-02-06 Thread Bas
=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

Re: a numarray question

2006-02-15 Thread Bas
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

Re: algorithm, optimization, or other problem?

2006-02-21 Thread Bas
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

Re: Matplotlib logarithmic scatter plot

2006-02-27 Thread Bas
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

Is it possible to merge xrange and slice?

2007-04-30 Thread Bas
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

Re: FM synthesis using Numpy

2007-08-15 Thread Bas
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

Re: a good explanation

2006-05-25 Thread Bas
inite loop! Bas -- http://mail.python.org/mailman/listinfo/python-list

Re: type-checking support in Python?

2008-10-07 Thread Bas
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

Re: Need some advice

2008-10-21 Thread Bas
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

Re: Plotting Graphs + Bestfit lines

2008-06-13 Thread Bas
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

Re: Profiling, sum-comprehension vs reduce

2008-09-13 Thread Bas
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:

Re: matrix algebra

2008-09-24 Thread Bas
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

Re: Matplotlib Polar Plot Angles/Axes

2008-09-26 Thread Bas
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

Re: Matplotlib Polar Plot Angles/Axes

2008-09-26 Thread Bas
use list-comprehensions, that is the whole idea about using these kick-ass objects! Bas -- http://mail.python.org/mailman/listinfo/python-list

List of all syntactic sugar?

2006-04-14 Thread Bas
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

Re: List of all syntactic sugar?

2006-04-14 Thread Bas
>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

Re: medians for degree measurements

2010-01-25 Thread Bas
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

Re: medians for degree measurements

2010-01-25 Thread Bas
> 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

Re: medians for degree measurements

2010-01-25 Thread Bas
> >> 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

Re: getting properly one subprocess output

2009-11-20 Thread Bas
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&

Re: lambda with floats

2010-04-09 Thread Bas
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

Re: Too much code - slicing

2010-09-17 Thread Bas
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

Obj.'s writing self-regeneration script ?

2005-07-08 Thread Bas Michielsen
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

Re: Obj.'s writing self-regeneration script ?

2005-07-08 Thread Bas Michielsen
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

Re: emulate a serial port in windows (create a virtual 'com' port)

2007-01-31 Thread Bas-i
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

Re: Using SWIG to build C++ extension

2008-07-11 Thread Bas Michielsen
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

pytone / _bsddb

2005-03-03 Thread Bas van Gils
-- 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

Re: pytone / _bsddb

2005-03-03 Thread Bas van Gils
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: [

OrderedEnum examples

2013-07-30 Thread Bas van der Wulp
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.

Re: OrderedEnum examples

2013-07-30 Thread Bas van der Wulp
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