Created on 2011-10-23 22:32 by carlo.verre, last changed 2022-04-11 14:57 by admin. This issue is now closed.
| Files |
|
|
|
| File name |
Uploaded |
Description |
Edit |
| decumulate.py |
carlo.verre,2011-10-23 22:32 |
|
|
| Messages (4) |
|
|
| msg146263 - (view) |
Author: Carlo Verre (carlo.verre) |
Date: 2011-10-23 22:32 |
| After in Python 3.2 the accumulate() function has been added to itertools module, for self-evident reasons of completeness and symmetry we could add in 3.3 the inverse decumulate() function, which, given the iterable argument p, yields p[0], p[1] - p[0], p[2] - p[1]... Its equivalent python form is in the attached file decumulate.py, below. |
|
|
| msg146290 - (view) |
Author: Alyssa Coghlan (ncoghlan) *  |
Date: 2011-10-24 10:45 |
| OK, looking at the code I realised what you're trying to get at is the idea of reporting the differences between values in a series, such that: x = list(accumulate(seq)) assert x == list(accumulate(differences(x))) I don't think the use cases are there to justify the addition (not every iterator we can think of should be a building block in itertools), but if such a thing were to be added, "differences" would convey the intention significantly better than the invented term "decumulate". |
|
|
| msg166167 - (view) |
Author: Ezio Melotti (ezio.melotti) *  |
Date: 2012-07-22 20:29 |
| I don't think this should go in itertools. It could go in the recipes at the bottom of the itertools doc, if you can provide some valid use cases (and possibly a patch too). |
|
|
| msg168260 - (view) |
Author: Raymond Hettinger (rhettinger) *  |
Date: 2012-08-15 05:40 |
| I also agree that the itertools module doesn't need this. (Reasons of "symmetry" are insufficient to make the module fatter that it already is). In addition, there are already a number of simple ways to do this. |
|
|
| History |
|
|
|
| Date |
User |
Action |
Args |
| 2022-04-11 14:57:23 |
admin |
set |
github: 57461 |
| 2012-08-15 05:40:23 |
rhettinger |
set |
status: open -> closedresolution: rejectedmessages: + |
| 2012-07-23 04:33:01 |
rhettinger |
set |
priority: normal -> lowassignee: rhettinger |
| 2012-07-22 20:29:18 |
ezio.melotti |
set |
versions: + Python 3.4, - Python 3.3nosy: + ezio.melottimessages: + stage: needs patch |
| 2011-10-24 10:45:04 |
ncoghlan |
set |
nosy: + ncoghlanmessages: + |
| 2011-10-24 06:46:54 |
petri.lehtinen |
set |
nosy: + petri.lehtinen |
| 2011-10-23 22:32:47 |
carlo.verre |
create |
|