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

Nathan Rice nathan.alexander.rice at gmail.com
Wed Dec 21 13:27:28 EST 2011


> It doesn't seem to work correctly when both operands are Elementwise:
>
>>>> numerator = ElementwiseProxy(range(5))
>>>> denominator = ElementwiseProxy([2, 2, 3, 3, 3])
>>>> remainder = numerator % denominator
>>>> print remainder
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "elementwise.py", line 72, in __repr__
>    return ", ".join(e.__repr__() for e in
> object.__getattribute__(self, "iterable"))
> TypeError: sequence item 0: expected string, ElementwiseProxy found
>>>> list(remainder)
> []
>
> Cheers,
> Ian

Ian, can you clarify the expected output in that case?  My initial
guess would be that you want to do a modulo on the cartesian product
of parameters from the proxies, sort of like:

import itertools
numerator = range(5)
denominator = [2, 2, 3, 3, 3]

remainder = [n % d for (n, d) in itertools.product(numerator, denominator)]

Nathan



More information about the Python-list mailing list