Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #17667

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!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-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'bug': 0.02; 'skip': 0.04; 'patterns': 0.05; 'unexpected': 0.07; 'url:py': 0.07; '[1]:': 0.09; '[2]:': 0.09; '[3]:': 0.09; 'subject:method': 0.09; 'url:github': 0.09; 'error:': 0.10; '**kwargs):': 0.16; '*args,': 0.16; '0))': 0.16; 'alchemy': 0.16; 'passed.': 0.16; 'self)': 0.16; 'subject:function': 0.16; 'subject:python.': 0.16; 'subject:release': 0.16; 'url:blob': 0.16; '\xa0def': 0.16; 'instance': 0.18; 'occurred': 0.18; 'input': 0.22; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'fine': 0.24; 'traceback': 0.24; 'says': 0.25; 'tests': 0.25; 'code': 0.25; 'suggestion': 0.26; 'import': 0.27; 'code,': 0.27; 'invalid': 0.28; 'message- id:@mail.gmail.com': 0.28; 'error': 0.29; 'class': 0.29; 'lines': 0.30; 'subject:support': 0.30; 'returning': 0.32; 'received:209.85.160': 0.33; 'object': 0.33; 'to:addr:python- list': 0.34; 'something': 0.35; 'received:209.85.160.46': 0.35; 'received:mail-pw0-f46.google.com': 0.35; 'operating': 0.35; 'similar': 0.36; 'to:name:python-list': 0.37; 'but': 0.37; 'received:google.com': 0.37; 'problems': 0.37; 'skip:_ 10': 0.37; 'doing': 0.38; 'some': 0.38; 'received:209.85': 0.38; 'skip:o 20': 0.38; 'first.': 0.39; "i'd": 0.39; 'should': 0.39; 'subject: (': 0.40; 'received:209': 0.40; 'to:addr:python.org': 0.40; 'move': 0.40; 'personal': 0.60; 'more': 0.61; 'body': 0.61; 'love': 0.62; 'soon.': 0.71; 'heavy': 0.71; 'corrupted': 0.84; 'nathan': 0.84; 'other):': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=rp2/3xLdvzhe/D+yeFFHls8WUGP3SQUmn05g/pwLRds=; b=Uw0bOhqzgonbr/9q7C1NxD6ZYWvQJR65p6WZ5NfztFr9ub4xPh2jV9VFme5CtuRtwU acNhN+Lb5Hnhdr+mEIpzGZv0zTdvV0Go1rnLfycEuxdeJlofWCH4pfUMyFyEXjOdCpbB VR8fplZMzSybvLTOGeJRaikoJ7pDkpHcV2UAI=
MIME-Version 1.0
In-Reply-To <b7f6acbd-f4c8-4910-971b-a6d897b30484@f8g2000prm.googlegroups.com>
References <CAOFbRmLyw88pHNSdszQY672ukAcm965jDUamXQGOFXoX9pd3+Q@mail.gmail.com> <CALwzidkOYp8FzfQ-s4wiNHy4TW3R03Cq7qQDSSNV=Zcf1OgQkA@mail.gmail.com> <mailman.3890.1324427093.27778.python-list@python.org> <b7f6acbd-f4c8-4910-971b-a6d897b30484@f8g2000prm.googlegroups.com>
Date Wed, 21 Dec 2011 10:15:38 -0500
Subject Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python.
From Nathan Rice <nathan.alexander.rice@gmail.com>
To python-list <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3915.1324480542.27778.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1324480542 news.xs4all.nl 6963 [2001:888:2000:d::a6]:49030
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:17667

Show key headers only | View raw


> Have you seen PyLINQ? It has a similar approach to operating on
> collections, returning a PyLINQ object after each call to facilitate
> chaining. https://github.com/kalessin/PyLINQ/blob/master/pylinq/linq.py

I hadn't seen it previously.  I am a VERY heavy user of SQL Alchemy
though, and I am sure chaining generative ClauseElements/Queries/etc,
has burned some patterns into my subconscious at this point.

> This is a personal opinion on the code, but I'd move instantiating the
> new ElementwiseProxy out of each method and into its own decorator:
>
>    # declare this outside of the class
>    def chainable(fn):
>        def _(self, *args, **kwargs):
>            return ElementwiseProxy(fn(self, *args, **kwargs), self)
>        return _
>
> This way, each method that is chainable is a little more obvious
> without inspecting the code, and the method body itself is only doing
> what the method says it does:
>
>    @chainable
>    def __add__(self, other):
>        return (e + other for e in object.__getattribute__(self,
> "iterable"))

This is a reasonable suggestion and I will play with something along
those lines soon.

> Incidentally, displaying an ElementwiseProxy instance doesn't go down
> well with iPython:
>
> In [1]: from elementwise import *
>
> In [2]: e = ElementwiseProxy(['one','two','three'])
>
> In [3]: e
> Out[3]: ERROR: An unexpected error occurred while tokenizing input
> The following traceback may be corrupted or invalid
> The error message is: ('EOF in multi-line statement', (6, 0))

I love IPython, but it has had known problems with iterators for
years.  A long time ago, I agonized over what I thought was a bug in
my code where itertools.count would skip numbers in IPython, but my
unit tests all passed.  Everything should work fine if you tuple() it
first.

Nathan

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-20 19:24 -0500
  Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. alex23 <wuwei23@gmail.com> - 2011-12-20 20:27 -0800
    Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-21 10:15 -0500
    Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. Robert Kern <robert.kern@gmail.com> - 2011-12-21 16:29 +0000
    Re: Elementwise -//- first release -//- Element-wise (vectorized) function, method and operator support for iterables in python. Nathan Rice <nathan.alexander.rice@gmail.com> - 2011-12-21 11:43 -0500

csiph-web