Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python.announce > #475
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news-out1.kabelfoon.nl!newsfeed.kabelfoon.nl!xindi.nntp.kabelfoon.nl!feed.xsnews.nl!border-1.ams.xsnews.nl!border2.hitnews.com!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <nathan.alexander.rice@gmail.com> |
| X-Original-To | python-announce-list@python.org |
| Delivered-To | python-announce-list@mail.python.org |
| X-Spam-Status | OK 0.010 |
| X-Spam-Evidence | '*H*': 0.98; '*S*': 0.00; '3.0,': 0.09; 'false,': 0.09; 'subject:method': 0.09; 'url:github': 0.09; 'url:packages': 0.09; '16,': 0.15; '1.5,': 0.16; '11.0,': 0.16; '3],': 0.16; '9.0,': 0.16; '[2,': 0.16; 'subject:graph': 0.16; 'subject:iterable': 0.16; 'subject:release': 0.16; '>>>': 0.18; 'to:2**1': 0.21; 'helpful': 0.23; "skip:' 40": 0.23; 'welcome.': 0.23; 'skip:" 30': 0.28; 'message-id:@mail.gmail.com': 0.28; "skip:' 30": 0.28; 'true,': 0.28; 'print': 0.29; 'received:209.85.210.46': 0.30; 'received:mail- pz0-f46.google.com': 0.30; 'objects': 0.32; 'to:addr:python-list': 0.33; '4.0': 0.34; 'url:python': 0.36; 'element': 0.36; 'to:addr :python-announce-list': 0.36; 'to:name:python-list': 0.36; 'received:google.com': 0.37; 'received:209.85': 0.38; 'url:org': 0.39; 'subject: (': 0.39; 'received:209': 0.39; 'to:addr:python.org': 0.40; 'skip:1 10': 0.63; 'sfxlen:3': 0.66; 'series': 0.67; '7.0,': 0.84; 'subject:calls': 0.84; '4.8': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=wy4i+mFH5zhhu9YuXiKmgSc4B0JjPXUIkyxVrieb15E=; b=SYjQpi4Lg8Ut0CbxPq18k+E2WHFz2cC7fLoamDyZQPvcyPclVlqPUcgulkd6YTF4LC 2Ze4m2NlgBnNk/QkBs+6rqmn30HsD4fM/cTUe7QbOpeQA2PyFNX8gtTjclotGsKxyglr MrqJGi8oK3oD41R3Hss61Lt8Kx6les7TFP+kM= |
| MIME-Version | 1.0 |
| Date | Mon, 16 Jan 2012 12:31:06 -0500 |
| Subject | Elementwise 0.120116 -//- beta release -//- Lazily compute functions, method calls and operations on all elements of an iterable (or graph). |
| From | Nathan Rice <nathan.alexander.rice@gmail.com> |
| To | python-list <python-list@python.org>, python-announce-list@python.org |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Mailman-Approved-At | Tue, 17 Jan 2012 02:36:13 +0100 |
| X-BeenThere | python-announce-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| Reply-To | python-list@python.org |
| List-Id | Announcement-only list for the Python programming language <python-announce-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-announce-list> |
| List-Post | <mailto:python-announce-list@python.org> |
| List-Help | <mailto:python-announce-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-announce-list>, <mailto:python-announce-list-request@python.org?subject=subscribe> |
| Approved | python-announce-list@python.org |
| Newsgroups | comp.lang.python.announce |
| Message-ID | <mailman.4804.1326764174.27778.python-announce-list@python.org> (permalink) |
| Lines | 72 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1326764174 news.xs4all.nl 6988 [2001:888:2000:d::a6]:37597 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python.announce:475 |
Show key headers only | View raw
Elementwise provides helpful proxy objects which let you perform a
series of computations on every element of an iterable or graph, in a
lazy manner.
Docs: http://packages.python.org/elementwise/
GitHub: https://github.com/nathan-rice/Elementwise
Examples:
The standard ElementwiseProxy:
>>> nums = ElementwiseProxy([1, 2, 3, 4)
>>> print nums.bit_length()
1, 2, 2, 3
>>> nums + 1
2, 3, 4, 5
>>> print nums * 2
2, 4, 6, 8
>>> print nums == 2
False, True, False, False
>>> print ((nums + 1) * 2 + 3).apply(float)
7.0, 9.0, 11.0, 13.0
>>> print (nums.apply(float) + 0.0001).apply(round, 2)
1.0, 2.0, 3.0, 4.0
>>> print abs(nums - 3)
2, 1, 0, 1
>>> print (nums * 2 + 3) / 4
>>> print efoo2.undo(3)
1, 2, 3, 4
>>> print ((nums * 2 + 3) / 4).replicate([2, 2, 3, 3])
1, 1, 2, 2
>>> words = ElementwiseProxy(["one", "two", "three", "four"])
>>> print (words + " little indians").upper().split("
").apply(reversed).apply("_".join) * 2
'INDIANS_LITTLE_ONEINDIANS_LITTLE_ONE',
'INDIANS_LITTLE_TWOINDIANS_LITTLE_TWO',
'INDIANS_LITTLE_THREEINDIANS_LITTLE_THREE',
'INDIANS_LITTLE_FOURINDIANS_LITTLE_FOUR'
The PairwiseProxy:
>>> nums = PairwiseProxy([1, 2, 3, 4])
>>> nums + [1, 2, 3, 4]
2, 4, 6, 8
>>> nums * [2, 2, 3, 3]
2, 4, 9, 12
>>> nums == [2, 2, 3, 5]
False, True, True, False
>>> (nums.apply(float) / itertools.count(2) +
itertools.count(1)).apply(round, args=itertools.repeat([2]))
1.5, 2.67, 3.75, 4.8
>>> abs(nums - [3, 2, 1, 1])
2, 0, 2, 3
>>> (nums * [2, 2, 1, 5] + [3, 5, 9, 0]) / [4, 1, 2, 3]
1, 9, 6, 6
>>> ((nums * itertools.repeat(2) + itertools.repeat(3)) /
itertools.repeat(4)).replicate([2, 2, 3, 3])
1, 0, 0, 0
>>> ((nums * [2, 3, 4, 5]) > [5, 6, 7, 8]) != [True, True, False, True]
True, True, True, False
The RecursiveElementwiseProxy:
>>> treenums = RecursiveElementwiseProxy([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
>>> treenums + 1
((2, 3, 4), (5, 6, 7), (8, 9, 10))
>>> treenums * 2
((2, 4, 6), (8, 10, 12), (14, 16, 18))
>>> (treenums * 2 + 1).apply(float)
((3.0, 5.0, 7.0), (9.0, 11.0, 13.0), (15.0, 17.0, 19.0))
Feedback is welcome.
Back to comp.lang.python.announce | Previous | Next | Find similar | Unroll thread
Elementwise 0.120116 -//- beta release -//- Lazily compute functions, method calls and operations on all elements of an iterable (or graph). Nathan Rice <nathan.alexander.rice@gmail.com> - 2012-01-16 12:31 -0500
csiph-web