Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Ned Batchelder
the code again, with indentation fixed: def myzip(*args): iters = map(iter, args) while iters: res = [next(i) for i in iters] yield tuple(res) Ugh. When I see "while foo", my brain says, "OK, you're about to see a loop which is controlled by the va

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 11:45 AM, Roy Smith wrote: >> I take it as "result", which makes plenty of sense to me. > > OK, so spell it out. Three more keystrokes (well, plus another three > when you use it on the next line). And one of them is a vowel; they > don't even cost much. The next guy who

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Roy Smith
In article , Chris Angelico wrote: > > Next problem, what the heck is "res"? We're not back in the punch-card > > days. We don't have to abbreviate variable names to save columns. > > Variable names are supposed to describe what they hold, and thus help > > you understand the code. I have no

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Terry Reedy
the code again, with indentation fixed: def myzip(*args): iters = map(iter, args) while iters: res = [next(i) for i in iters] yield tuple(res) Ugh. When I see "while foo", my brain says, "OK, you're about to see a loop which is controlled by the va

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 11:27 AM, Roy Smith wrote: > Although, to be honest, I'm wondering if this is more straight-forward > (also not tested): > > def myzip37(*args): > if not args: > return > iters = list(map(iter, args)) Yes, I prefer this too. It

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 11:12 AM, Roy Smith wrote: > Ugh. When I see "while foo", my brain says, "OK, you're about to see a > loop which is controlled by the value of foo being changed inside the > loop". That's not at all what's happening here, so my brain runs into a > wall. I agree, with the

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Roy Smith
In article , Chris Angelico wrote: > On Mon, Dec 8, 2014 at 10:33 AM, Steven D'Aprano > wrote: > > How would we re-write this to work in the future Python 3.7? Unless I have > > missed something, I think we could write it like this: > > > > def myzip37(*a

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Roy Smith
e code again, with indentation fixed: > > > def myzip(*args): > iters = map(iter, args) > while iters: > res = [next(i) for i in iters] > yield tuple(res) Ugh. When I see "while foo", my brain says, "OK, you're about to see a loop which i

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 10:33 AM, Steven D'Aprano wrote: > How would we re-write this to work in the future Python 3.7? Unless I have > missed something, I think we could write it like this: > > def myzip37(*args): > iters = list(map(iter, args)) > whi

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Steven D'Aprano
quot; makes it return immediately >> instead. >> >> So it seems this example is even more confusing than you thought. > > I'm actually glad PEP 479 will break this kind of code. Gives a good > excuse for rewriting it to be more readable. What kind of code is that? Sh

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
On Mon, Dec 8, 2014 at 5:27 AM, Ian Kelly wrote: > On Dec 7, 2014 8:31 AM, "Ned Batchelder" wrote: >> NOTE: THIS EXAMPLE IS HORRIBLE. This code is crazy-confusing, and should >> never have been used as an example of iteration. It layers at least three >> iterations on top of each other, making i

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Ian Kelly
On Dec 7, 2014 8:31 AM, "Ned Batchelder" wrote: > NOTE: THIS EXAMPLE IS HORRIBLE. This code is crazy-confusing, and should never have been used as an example of iteration. It layers at least three iterations on top of each other, making it very difficult to see what is going on. It uses "while i

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
ith a suggestion to try passing it no args, which won't work because of that (or at least, won't work in Py2; in Py3, iters will indeed never be false, unless you use list() to coalesce the map). This is something which definitely ought to have been given a comment. Or, more usefully, a g

RE: Python Iterables struggling using map() built-in

2014-12-07 Thread Ivan Evstegneev
ython-list@python.org Subject: Re: Python Iterables struggling using map() built-in On 12/6/14 11:44 AM, Ivan Evstegneev wrote: > And as I've promised the question section: > > 1.What actually map() trying to do in Python 3.X? > > I mean, why is this works fine: > >>&g

Re: Python Iterables struggling using map() built-in

2014-12-07 Thread Chris Angelico
k= myzip(1, 2, 3, 4) > >>>> next(k) > > > > I got this result: > > > > Traceback (most recent call last): > > File "", line 1, in > > next(k) > > File "", line 2, in myzip > > iters = list(map(iter, arg

Python Iterables struggling using map() built-in

2014-12-07 Thread Ivan Evstegneev
act that I did some RTFM before posting. Links: 1. map() built-in definitions: https://docs.python.org/3/library/functions.html#map -for Python 3.X https://docs.python.org/2.6/library/functions.html#map - for Python 2.6.X 2. Glossary definitions of "iterable " an

Re: Using map()

2014-11-16 Thread Ian Kelly
On Sun, Nov 16, 2014 at 4:22 PM, Terry Reedy wrote: > If pylint sees 'map(lambda ...: ', it would be appropriate to suggest using > a comprehension or generator expression instead. This avoids the unneeded > creation and repeated call of a new function. There's actuall

Re: Messages from code analysis tools (was: Using map())

2014-11-16 Thread Chris Angelico
On Mon, Nov 17, 2014 at 12:21 PM, Ben Finney wrote: >> The pylint message that always irked me was: >> >> W0142: Used * or ** magic >> >> "magic"? They're features of the language! > > It's a warning, because the use of that feature clobbers the static code > inspection you've asked for. PyLin

Re: Using map()

2014-11-16 Thread Dan Stromberg
On Sun, Nov 16, 2014 at 4:09 PM, Steven D'Aprano wrote: > Pavel Volkov wrote: > >> I checked my modules with pylint and saw the following warning: >> >> W: 25,29: Used builtin function 'map' (bad-builtin) >> >> Why is the use of map() discourag

Messages from code analysis tools (was: Using map())

2014-11-16 Thread Ben Finney
Ned Batchelder writes: > Pylint isn't useful until you've tailored the messages. Definitely agreed. > The pylint message that always irked me was: > > W0142: Used * or ** magic > > "magic"? They're features of the language! It's a warning, because the use of that feature clobbers the stati

Re: Using map()

2014-11-16 Thread Chris Angelico
On Mon, Nov 17, 2014 at 11:24 AM, Ned Batchelder wrote: > Pylint isn't useful until you've tailored the messages. Personally, I avoid > map, but your usage may vary. The pylint message that always irked me was: > > W0142: Used * or ** magic This is why I don't

Re: Using map()

2014-11-16 Thread Ned Batchelder
On 11/16/14 7:09 PM, Steven D'Aprano wrote: Pavel Volkov wrote: I checked my modules with pylint and saw the following warning: W: 25,29: Used builtin function 'map' (bad-builtin) Why is the use of map() discouraged? It' such a useful thing. That's a bug in pylin

Re: Using map()

2014-11-16 Thread Steven D'Aprano
Pavel Volkov wrote: > I checked my modules with pylint and saw the following warning: > > W: 25,29: Used builtin function 'map' (bad-builtin) > > Why is the use of map() discouraged? > It' such a useful thing. That's a bug in pylint. It's not a bad

Re: Using map()

2014-11-16 Thread Terry Reedy
On 11/16/2014 8:01 AM, Pavel Volkov wrote: I checked my modules with pylint and saw the following warning: W: 25,29: Used builtin function 'map' (bad-builtin) Why is the use of map() discouraged? It' such a useful thing. I consider that to be a bug in pylint. It misstates

RE: Using map()

2014-11-16 Thread Joseph L. Casale
> I checked my modules with pylint and saw the following warning: > > W: 25,29: Used builtin function 'map' (bad-builtin) > > Why is the use of map() discouraged? > It' such a useful thing. The warning manifests from the opinion that a comprehension is more suit

Re: Using map()

2014-11-16 Thread Joel Goldstick
On Sun, Nov 16, 2014 at 8:01 AM, Pavel Volkov wrote: > I checked my modules with pylint and saw the following warning: > > W: 25,29: Used builtin function 'map' (bad-builtin) > > Why is the use of map() discouraged? > It' such a useful thing. > -- > https://

Using map()

2014-11-16 Thread Pavel Volkov
I checked my modules with pylint and saw the following warning: W: 25,29: Used builtin function 'map' (bad-builtin) Why is the use of map() discouraged? It' such a useful thing. -- https://mail.python.org/mailman/listinfo/python-list

Re: 2d color-bar map plot

2014-10-17 Thread Mark Lawrence
On 17/10/2014 07:28, Dhananjay wrote: Dear all, I am bit new to the python/pyplot. This might be simple, but I guess I am missing something here. I doubt that you'll get detailed answers here so suggest you try https://lists.sourceforge.net/lists/listinfo/matplotlib-users which is also availa

Re: 2d color-bar map plot

2014-10-17 Thread Peter Pearson
On Fri, 17 Oct 2014 14:28:13 +0800, Dhananjay wrote: [snip] > xs = ys = zs = [] > for line in fl1: > line = line.split() > xs.append(float(line[0])) > ys.append(float(line[1])) > zs.append(float(line[2])) > > print xs[0], ys[0], zs[0] The line "xs = ys = zs = []" is almost surely n

2d color-bar map plot

2014-10-16 Thread Dhananjay
,z axis data points. This is not a continuous data. I wish to make a plot as a 2D with 3rd dimension (i.e z-axis data) as a color map with color bar on right hand side. As a beginner, I tried to follow tutorial with some modification as follows: http://matplotlib.org/examples/pylab_examples

Re: Fwd: How to draw a map using python

2014-08-10 Thread Mark Lawrence
On 10/08/2014 02:44, Yuanchao Xu wrote: To kind whom it may concern: I want to draw a map using python, not really a map with full information, just a get together of a series of small shapes to reflect land use. The data is like below |1 2 2 3 3 2 2 3 3 1 1 2 1 1 1 1 3 3 3 3

Re: How to draw a map using python

2014-08-10 Thread Ian Kelly
On Sat, Aug 9, 2014 at 7:44 PM, Yuanchao Xu wrote: > 1. I wonder in python, is there any more fast way to generate this kind of > map, as a whole, not a series of shapes, i think that would be faster?? You mean like collecting all the shapes into a single sparse array and passing the

Fwd: How to draw a map using python

2014-08-09 Thread Yuanchao Xu
To kind whom it may concern: I want to draw a map using python, not really a map with full information, just a get together of a series of small shapes to reflect land use. The data is like below 1 2 2 3 3 22 3 3 1 1 21 1 1 1 3 33 3 3 3 4 1 Each number represents one land use type. and their

Re: asyncio with map&reduce flavor and without flooding the event loop

2014-08-06 Thread Maxime Steisel
ent loop nor to > overload our network. We'd like to control the task flow. This is what I > achieve well with modification of nice Maxime's solution proposed here: > https://mail.python.org/pipermail/python-list/2014-July/675048.html > > Well, but I'd need a

asyncio with map&reduce flavor and without flooding the event loop

2014-08-03 Thread Valery Khamenya
ed as well a very natural thing, kind of map() & reduce() or functools.reduce() if we are on python3 already. That is, I'd need to call a "summarizing" function for all the downloading tasks completed on links from a page. This is where i fail :( I'd propose an oversimpl

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-28 Thread Duncan Booth
Chris Angelico wrote: > # Snapshot of keys: > for k in list(d): > if f(k): del d[k] > > No extra loop at the end, no switching out and in of contents, just > one little change in the loop header. Obviously you don't want to do > this when you're deleting two out of three billion, but for sma

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-26 Thread Roy Smith
In article <535c67e9$0$29965$c3e8da3$54964...@news.astraweb.com>, Steven D'Aprano wrote: > I think the two obviously good enough approaches are: > > - save a "to be deleted" list, then delete those keys; > > - copy the "not to be deleted" items into a new dict There is a third possibility: I

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-26 Thread Chris Angelico
On Sun, Apr 27, 2014 at 12:14 PM, Steven D'Aprano wrote: > I think the two obviously good enough approaches are: > > - save a "to be deleted" list, then delete those keys; > > - copy the "not to be deleted" items into a new dict For a small enough dict that the performance question doesn't matter

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-26 Thread Steven D'Aprano
On Sat, 26 Apr 2014 12:25:27 -0700, Charles Hixson wrote: > On 04/25/2014 10:53 AM, Charles Hixson wrote: >> What is the proper way to delete selected items during iteration of a >> map? What I want to do is: >> >> for (k, v) in m.items(): >>if f(k): >&g

Re: Proper deletion of selected items during map iteration in for loop

2014-04-26 Thread Peter Otten
Charles Hixson wrote: > What is the proper way to delete selected items during iteration of a > map? What I want to do is: > > for (k, v) in m.items(): > if f(k): ># do some processing of v and save result elsewhere >del m[k] > > But this g

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-26 Thread Tim Chase
On 2014-04-26 12:25, Charles Hixson wrote: > I expect that I'll be deleting around 1/3 during > each iteration of the process...and then adding new ones back in. > There shouldn't be a really huge number of deletions on any > particular pass, but it will be looped through many times... If you have

Re: Proper deletion of selected items during map iteration in for loop: Thanks to all

2014-04-26 Thread Charles Hixson
On 04/25/2014 10:53 AM, Charles Hixson wrote: What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be expected

Re: Proper deletion of selected items during map iteration in for loop

2014-04-25 Thread Tim Chase
On 2014-04-25 14:50, Terry Reedy wrote: > If you expect to delete more than half the keys *and* if there are > no other references to the dict, such that you need the particular > object mutated, this might be better. If that's your precondition, then it might be better to do something like kee

Re: Proper deletion of selected items during map iteration in for loop

2014-04-25 Thread Terry Reedy
On 4/25/2014 2:04 PM, Matthew Barnett wrote: On 2014-04-25 18:53, Charles Hixson wrote: What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere

Re: Proper deletion of selected items during map iteration in for loop

2014-04-25 Thread Matthew Barnett
On 2014-04-25 18:53, Charles Hixson wrote: What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be

Re: Proper deletion of selected items during map iteration in for loop

2014-04-25 Thread Chris Angelico
On Sat, Apr 26, 2014 at 3:53 AM, Charles Hixson wrote: > What is the proper way to delete selected items during iteration of a map? > What I want to do is: > > for (k, v) in m.items(): >if f(k): > # do some processing of v and save result elsewhere > del m[

Proper deletion of selected items during map iteration in for loop

2014-04-25 Thread Charles Hixson
What is the proper way to delete selected items during iteration of a map? What I want to do is: for (k, v) in m.items(): if f(k): # do some processing of v and save result elsewhere del m[k] But this gives (as should be expected): RuntimeError: dictionary changed size

simple ElementTree based parser that allows entity definition map

2013-12-04 Thread Robin Becker
#x27;ca': '123'}, [], None), '22'], None)], None) ('a', {}, ['a=&=b< >'], None) ('a', {}, [u'amp=& moo=&moo; lt=< gt=> mu=… foo=AAA&fum;BBB'], None) ie the result of the &foo; lookup is not re-parsed so &fum; is not translated. Is there a way to get a simple ElementTree based parser that can do what I want? I have several hundred entities and the size of the DTD would probably be larger than 99% of the strings I need to parse. I think I can live with the non-reparsing of the map output, but can I get Python 3 to do the UseForeignDTD thing? -- Robin Becker -- https://mail.python.org/mailman/listinfo/python-list

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Luca Cerone
Thanks for the help Peter! > > > > >> def make_instancemethod(inst, methodname): > > >> return getattr(inst, methodname) > > > > > > This is just getattr -- you can replace the two uses of > > > make_instancemethod with getattr and delete this ;). > > > > D'oh ;) -- http://mail.py

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Joshua Landau
On 7 August 2013 23:26, Luca Cerone wrote: > Thanks for the post. > I actually don't know exactly what can and can't be pickles.. I just try it and see what works ;). The general idea is that if it is module-level it can be pickled and if it is defined inside of something else it cannot. It depe

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Luca Cerone
Thanks for the post. I actually don't know exactly what can and can't be pickles.. not what partialing a function means.. Maybe can you link me to some resources? I still can't understand all the details in your code :) -- http://mail.python.org/mailman/listinfo/python-list

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Peter Otten
Joshua Landau wrote: > On 7 August 2013 15:46, Peter Otten <__pete...@web.de> wrote: >> def make_instancemethod(inst, methodname): >> return getattr(inst, methodname) > > This is just getattr -- you can replace the two uses of > make_instancemethod with getattr and delete this ;). D'oh ;)

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Joshua Landau
On 7 August 2013 15:46, Peter Otten <__pete...@web.de> wrote: > import copy_reg > import multiprocessing > import new "new" is deprecated from 2.6+; use types.MethodType instead of new.instancemethod. > def make_instancemethod(inst, methodname): > return getattr(inst, methodname) This is jus

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Peter Otten
Joshua Landau wrote: > On 7 August 2013 11:10, Luca Cerone wrote: >> I can't try it now, I'll let you know later if it works! >> (Though just by reading I can't really understand what the code does). > > Well, > >>> from multiprocessing import Pool >>> from functools import partial >>> >>> clas

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Joshua Landau
On 7 August 2013 11:10, Luca Cerone wrote: > I can't try it now, I'll let you know later if it works! > (Though just by reading I can't really understand what the code does). Well, >> from multiprocessing import Pool >> from functools import partial >> >> class A(object): >> def __init__(sel

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Luca Cerone
> > doesn't work neither in Python 2.7, nor 3.2 (by the way I can't use Python > > 3 for my application). > > Are you using Windows? Over here on 3.3 on Linux it does. Not on 2.7 though. No I am using Ubuntu (12.04, 64 bit).. maybe things changed from 3.2 to 3.3? > from multiprocessing import

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Joshua Landau
On 7 August 2013 09:33, Luca Cerone wrote: > To correct my example: > > from multiprocessing import Pool > > class A(object): > def __init__(self,x): > self.value = x > def fun(self,x): > return self.value**x > > l = range(100) > p = Pool(4) > op = p.map(A(3).fun, l) > > do

Re: Using Pool map with a method of a class and a list

2013-08-07 Thread Luca Cerone
Hi Joshua thanks! > I think you might not understand what Chris said. > Currently this does *not* work with Python 2.7 as you suggested it would. > >>> op = map(A.fun,l) Yeah actually that wouldn't work even in Python 3, since value attribute used by fun has not been se

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Joshua Landau
in > the ML :) I think you might not understand what Chris said. Currently this does *not* work with Python 2.7 as you suggested it would. >>> op = map(A.fun,l) Traceback (most recent call last): File "", line 1, in TypeError: unbound method fun() must be called wi

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Luca Cerone
Hi Chris, thanks > Do you ever instantiate any A() objects? You're attempting to call an > > unbound method without passing it a 'self'. I have tried a lot of variations, instantiating the object, creating lambda functions that use the unbound version of fun (A.fun.__func__) etc etc.. I have pl

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Luca Cerone
> > > class A(object): > >def __init__(self,x): > >self.value = x > >def fun(self,x): > >return self.value**x > > > > > > l = range(10) > > > > p = Pool(4) > > > > op = p.map(A.fun,l)

Re: Using Pool map with a method of a class and a list

2013-08-06 Thread Chris Angelico
On Tue, Aug 6, 2013 at 6:12 PM, Luca Cerone wrote: > from multiprocessing import Pool > > class A(object): >def __init__(self,x): >self.value = x >def fun(self,x): >return self.value**x > > > l = range(10) > > p = Pool(4) > > op = p.map(A.fun,l) Do you ever instantiate any

Using Pool map with a method of a class and a list

2013-08-06 Thread Luca Cerone
) p = Pool(4) op = p.map(A.fun,l) #using this with the normal map doesn't cause any problem This fails because it says that the methods can't be pickled. (I assume it has something to do with the note in the documentation: "functionality within this package requires that the __m

Re: 2-D drawing/map with python

2013-03-14 Thread Matteo Boscolo
Il 12/03/2013 16:58, Huseyin Emre Guner ha scritto: Hello, I am newbie in Python. I would like to make a project using python. The main ideo of this project is that a user enters the x,y values to the Gui(PyQt or Gtk) and then a 2-D map is plotted due to the x,y values. First, I use Pygame

2-D drawing/map with python

2013-03-12 Thread Huseyin Emre Guner
Hello, I am newbie in Python. I would like to make a project using python. The main ideo of this project is that a user enters the x,y values to the Gui(PyQt or Gtk) and then a 2-D map is plotted due to the x,y values. First, I use Pygame commands "(pygame.draw.line(window, (255, 255

Re: Issue with seeded map generation

2012-12-08 Thread Ian Kelly
e overkill > for what I need), but I want to update the item/monster locations so the > player can drop an item and come back to it later. Make the level generation process two-step. Step 1, build the map. Step 2, populate it with items and monsters. When the level is left, save the state

Re: Issue with seeded map generation

2012-12-08 Thread Hans Mulder
On 8/12/12 22:32:22, Graham Fielding wrote: > Hey, all! > > I've managed to get my project to a semi-playable state (everything > functions, if not precisely the way I'd like it to). One small issue is > that when the player moves from one level to the next, the items and > monsters in the previ

Re: Issue with seeded map generation

2012-12-08 Thread Mitya Sirenef
be ok to to simply save the level in memory under its number; if the map takes up a lot of space you can make objects take up less memory by using __slots__, and then change levels by doing something like this: def change_level(num): self.levels[self.current_lvl] = self.levelmap if num in self.

Issue with seeded map generation

2012-12-08 Thread Graham Fielding
Hey, all! I've managed to get my project to a semi-playable state (everything functions, if not precisely the way I'd like it to). One small issue is that when the player movs from one level to the next, the items and monsters in the previous level all 'reset' and return to the positions th

Re: fmap(), "inverse" of Python map() function

2012-10-06 Thread vasudevram
> Thanks to all who replied. Always good to learn something new. P.S. A reader posted a good comment with Scala as well as Python code for a compose function (basically same functionality as fmap, or more - the compose once, run many times thing). It's the 4th comment on my blog post. - Vasud

Re: fmap(), "inverse" of Python map() function

2012-10-06 Thread vasudevram
On Saturday, October 6, 2012 5:01:40 AM UTC+5:30, Devin Jeanpierre wrote: > On Fri, Oct 5, 2012 at 7:24 PM, Ian Kelly wrote: > > > I realize that. My point is that the function *feels* more like a > > > variant of reduce than of map. > > > > > >> If

Re: fmap(), "inverse" of Python map() function

2012-10-05 Thread Devin Jeanpierre
On Fri, Oct 5, 2012 at 7:24 PM, Ian Kelly wrote: > I realize that. My point is that the function *feels* more like a > variant of reduce than of map. > >> If it's meant as a complaint, it's a poor one. > > It's not. Fair enough all around. Sorry for

Re: fmap(), "inverse" of Python map() function

2012-10-05 Thread Ian Kelly
On Fri, Oct 5, 2012 at 4:52 PM, Devin Jeanpierre wrote: > On Fri, Oct 5, 2012 at 5:31 PM, Ian Kelly wrote: >> On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: >>> >>> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html >> >> Your f

Re: fmap(), "inverse" of Python map() function

2012-10-05 Thread Devin Jeanpierre
On Fri, Oct 5, 2012 at 5:31 PM, Ian Kelly wrote: > On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: >> >> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html > > Your fmap is a special case of reduce. So is map. def map(f, seq): return reduce

Re: fmap(), "inverse" of Python map() function

2012-10-05 Thread Ian Kelly
On Fri, Oct 5, 2012 at 3:31 PM, Ian Kelly wrote: > On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: >> >> http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html > > Your fmap is a special case of reduce. > > def fmap(functions, argument): >

Re: fmap(), "inverse" of Python map() function

2012-10-05 Thread Ian Kelly
On Fri, Oct 5, 2012 at 2:19 PM, vasudevram wrote: > > http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html Your fmap is a special case of reduce. def fmap(functions, argument): return reduce(lambda result, func: func(result), functions, argument) --

fmap(), "inverse" of Python map() function

2012-10-05 Thread vasudevram
http://jugad2.blogspot.in/2012/10/fmap-inverse-of-python-map-function.html - Vasudev Ram www.dancingbison.com jugad2.blogspot.com twitter.com/vasudevram -- http://mail.python.org/mailman/listinfo/python-list

Re: Faster way to map numpy arrays

2012-06-26 Thread Oscar Benjamin
he indices. In my experience the fastest way to do something like this would be to use cython as suggested above by Stefan. Oscar. > > Saurabh > > > > > > On 25 June 2012 08:24, Stefan Behnel > wrote: > > Saurabh Kabra, 25.06.2012 05:37: >> > I have wr

Re: Faster way to map numpy arrays

2012-06-25 Thread Saurabh Kabra
). But I solved that problem by simply adding zero elements to make a regular 3D numpy array out of the list. Saurabh On 25 June 2012 08:24, Stefan Behnel wrote: > Saurabh Kabra, 25.06.2012 05:37: > > I have written a script to map a 2D numpy array(A) onto another array(B) > of &

Re: Faster way to map numpy arrays

2012-06-25 Thread Oscar Benjamin
On 25 June 2012 08:24, Stefan Behnel wrote: > Saurabh Kabra, 25.06.2012 05:37: > > I have written a script to map a 2D numpy array(A) onto another array(B) > of > > different dimension. more than one element (of array A) are summed and > > mapped to each element of arr

Re: Faster way to map numpy arrays

2012-06-25 Thread Stefan Behnel
Saurabh Kabra, 25.06.2012 05:37: > I have written a script to map a 2D numpy array(A) onto another array(B) of > different dimension. more than one element (of array A) are summed and > mapped to each element of array B. To achieve this I create a list where I > store the index of a

Faster way to map numpy arrays

2012-06-24 Thread Saurabh Kabra
I have written a script to map a 2D numpy array(A) onto another array(B) of different dimension. more than one element (of array A) are summed and mapped to each element of array B. To achieve this I create a list where I store the index of array A to be mapped to array B. The list is the

Re: Looking for Python script for Vector Map simplification, preserving shape and topology

2012-05-17 Thread Simon Cropper
On 18/05/12 03:46, David Shi wrote: Dear All, I am looking for Python script for Vector Map simplification, preserving shape and topology. Please get in touch with davidg...@yahoo.co.uk Regards. David David, You really need to provide more information to get a specific answer; what

Looking for Python script for Vector Map simplification, preserving shape and topology

2012-05-17 Thread David Shi
Dear All, I am looking for Python script for Vector Map simplification, preserving shape and topology. Please get in touch with davidg...@yahoo.co.uk    Regards. David -- http://mail.python.org/mailman/listinfo/python-list

Re: options for plotting points on geographic map

2011-10-01 Thread CM
> You could create the webpage and then render > it in your desktop app. I have seen plenty of apps like that. That's a good idea. I was able to get the basics of the pymaps approach going, so I may do just this. Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: options for plotting points on geographic map

2011-10-01 Thread CM
On Sep 29, 12:52 pm, Miki Tebeka wrote: > Probably the google maps routes will be faster (maybe using embedded webkit > window). However it requires internet connection. > > See alsohttp://www.scipy.org/Cookbook/Matplotlib/Maps Thanks. But I just needed a small radius, not the whole globe, and

RE: options for plotting points on geographic map

2011-09-29 Thread Prasad, Ramit
>I see there is pymaps, a Python wrapper for Google Maps. I may try >that but it seems to be barely documented and would require making a >webpage with javascript to display the map, whereas I'd probably >prefer a desktop app for this--though I'd consider a web page (it

Re: options for plotting points on geographic map

2011-09-29 Thread Miki Tebeka
Probably the google maps routes will be faster (maybe using embedded webkit window). However it requires internet connection. See also http://www.scipy.org/Cookbook/Matplotlib/Maps HTH -- Miki Tebeka http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list

options for plotting points on geographic map

2011-09-28 Thread CM
Recommendations sought for using Python to plot points/custom markers (and maybe other things?) on a map of an area of the U.S. of maybe 100 miles radius. (This would be a "political" map showing towns, such as from Google Maps or Mapquest, and not a "physical" map). I'

Map-based module imports with import hook

2011-08-01 Thread mpj
Hi, I've experience working at companies where, because of the network set up, having a long PYTHONPATH and searching it is quite a heavy task and can slow down the start up of the interpreter when there are lots of imports. As a proof of concept I wanted to look at a map-based approach

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-24 Thread Deeyana
On Tue, 24 May 2011 13:39:15 -0700, asandroq wrote: > On May 24, 12:27 am, Deeyana wrote: >> >> Classic unsubstantiated and erroneous claim. Scheme does not come OOTB >> with any suitable libraries for host interop and though it can make >> calls to C libraries, doing so is awkward and involves d

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-24 Thread Chris Angelico
On Tue, May 24, 2011 at 8:27 AM, Deeyana wrote: > Classic unsubstantiated and erroneous claim. Scheme does not come OOTB > with any suitable libraries for host interop and though it can make calls > to C libraries, doing so is awkward and involves difficulties with the > impedance mismatch between

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-24 Thread asandroq
On May 24, 12:27 am, Deeyana wrote: > > Classic unsubstantiated and erroneous claim. Scheme does not come OOTB > with any suitable libraries for host interop and though it can make calls > to C libraries, doing so is awkward and involves difficulties with the > impedance mismatch between Scheme's

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-23 Thread Deeyana
On Mon, 23 May 2011 00:52:07 -0700, asandroq wrote: > On May 23, 4:29 am, Deeyana wrote: >> >> You might be interested in Clojure, then. Lists are more abstracted, >> like in Scheme, and vectors and also dictionaries/maps and sets are >> first class citizens along side lists. And unlike Scheme, C

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-23 Thread Antti J Ylikoski
On 23.5.2011 16:39, Pascal J. Bourguignon wrote: torb...@diku.dk (Torben Ægidius Mogensen) writes: Xah Lee writes: Functional Programing: stop using recursion, cons. Use map& vectors. 〈Guy Steele on Parallel Programing〉 http://xahlee.org/comp/Guy_Steele_parallel_computing.html Thi

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-23 Thread Pascal J. Bourguignon
torb...@diku.dk (Torben Ægidius Mogensen) writes: > Xah Lee writes: > > >> Functional Programing: stop using recursion, cons. Use map & vectors. >> >> 〈Guy Steele on Parallel Programing〉 >> http://xahlee.org/comp/Guy_Steele_parallel_computing.html > > T

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-23 Thread asandroq
On May 23, 4:29 am, Deeyana wrote: > > You might be interested in Clojure, then. Lists are more abstracted, like > in Scheme, and vectors and also dictionaries/maps and sets are first > class citizens along side lists. And unlike Scheme, Clojure has good > library/host interop support. You can wri

Re: Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-22 Thread Deeyana
On Sun, 22 May 2011 15:47:53 -0700, Xah Lee wrote: > this is important but i think most lispers and functional programers > still don't know it. > > Functional Programing: stop using recursion, cons. Use map & vectors. > > 〈Guy Steele on Parallel Programin

Functional Programing: stop using recursion, cons. Use map & vectors

2011-05-22 Thread Xah Lee
this is important but i think most lispers and functional programers still don't know it. Functional Programing: stop using recursion, cons. Use map & vectors. 〈Guy Steele on Parallel Programing〉 http://xahlee.org/comp/Guy_Steele_parallel_computing.html btw, lists (as cons, car, cd

Re: Simple map/reduce utility function for data analysis

2011-04-26 Thread Raymond Hettinger
On Apr 25, 7:42 pm, Paul Rubin wrote: > Raymond Hettinger writes: > > Here's a handy utility function for you guys to play with: > >    http://code.activestate.com/recipes/577676/ > > Cute, but why not use collections.defaultdict for the return dict? > Untested: My first draft had a defaultdict

<    1   2   3   4   5   6   7   8   9   >