Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Elementwise -//- first release -//- Element-wise (vectorized)function, method and operator support for iterables in python.

Reply
Thread Tools

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

 
 
Nathan Rice
Guest
Posts: n/a
 
      12-20-2011
Elementwise provides a proxy object for iterables which supports
chained method calls, as well as elementwise expressions and some
built-in functions.

Example:

class ExampleList(ElementwiseProxyMixin, list):
def __new__(cls, iterable):
return list.__new__(cls, iterable)
foo = ExampleList([1, 2, 3, 4])

# You could also do: efoo = ElementwiseProxy(foo)
efoo = foo.each

assert list(efoo.bit_length()) == [1, 2, 2, 3]
print "bit length: ", list(efoo.bit_length())
assert list(efoo + 1) == [2, 3, 4, 5]
print "with addition of 1: ", list(efoo + 1)
assert list(efoo * 2) == [2, 4, 6, 8]
print "with multiplication by 2: ", list(efoo * 2)
assert list(efoo == 2) == [False, True, False, False]
print "testing equality: ", efoo == 2
assert list((efoo + 1) * 2 + 3) == [7, 9, 11, 13]
print "chaining addition and multiplication: ", (efoo + 1) * 2 + 3

Each ElementwiseProxy also has a "parent" attribute so you can
backtrack in the chain as needed rather than store each intermediate
value, if you think you might need them.

There are still some issues with proper support of things like bool()
and int(), which refuse to return things that are not of the correct
type.

Get it:

PyPi: http://pypi.python.org/pypi/elementwise/0.111220
GitHub: https://github.com/nathan-rice/Elementwise

This was developed as a proof of concept for expanding the role of
element-wise syntax in python, and to that end I welcome comments.

Nathan Rice
 
Reply With Quote
 
 
 
 
Steven D'Aprano
Guest
Posts: n/a
 
      12-20-2011
On Tue, 20 Dec 2011 14:45:06 -0500, Nathan Rice wrote:

> PyPi: http://pypi.python.org/pypi/elementwise/0.111220


Version 0.111220? What do you do, bump the version number after every
keystroke?


--
Steven
 
Reply With Quote
 
 
 
 
Nathan Rice
Guest
Posts: n/a
 
      12-20-2011
If you take a moment and examine the version number, you will notice
that it is a date code. In my opinion that is far more informative
than an arbitrary number. I use the major version number to
signify... Wait for it... Major changes
 
Reply With Quote
 
MRAB
Guest
Posts: n/a
 
      12-20-2011
On 20/12/2011 20:29, Steven D'Aprano wrote:
> On Tue, 20 Dec 2011 14:45:06 -0500, Nathan Rice wrote:
>
>> PyPi: http://pypi.python.org/pypi/elementwise/0.111220

>
> Version 0.111220? What do you do, bump the version number after every
> keystroke?
>

It looks like it's based on the date. I do something similar with the
regex module, except that _my_ version number is Y2K compliant.
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      12-20-2011
On Tue, 20 Dec 2011 15:45:07 -0500, Nathan Rice wrote:

> If you take a moment and examine the version number, you will notice
> that it is a date code.


Not any date code I'm familiar with. 0.111220 doesn't look anything like
a date to me.

Possibly if the last release was two thousand years ago. I'd rather stick
to actively maintained software, if it's all the same with you.


> In my opinion that is far more informative than
> an arbitrary number. I use the major version number to signify... Wait
> for it... Major changes


Well, that's one opinion. Another opinion is that nobody cares what
specific day you release a new version, and that versions 0.191231 and
0.200101 probably aren't that big a difference.


--
Steven
 
Reply With Quote
 
Paul Rubin
Guest
Posts: n/a
 
      12-20-2011
Steven D'Aprano <(E-Mail Removed)> writes:
> Not any date code I'm familiar with. 0.111220 doesn't look anything like
> a date to me.


0 is the major version number. 111220 (the minor version number) is the
date code, 2011-12-20 being today.
 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      12-20-2011
On Wed, Dec 21, 2011 at 7:47 AM, MRAB <(E-Mail Removed)> wrote:
> It looks like it's based on the date. I do something similar with the
> regex module, except that _my_ version number is Y2K compliant.


The eight-digit date is a recognized entity. The truncated six-digit
form, much less so.

But either is better known than what PPWizard uses, which involves the
day-of-year...

ChrisA
 
Reply With Quote
 
Nathan Rice
Guest
Posts: n/a
 
      12-20-2011
On Tue, Dec 20, 2011 at 4:00 PM, Steven D'Aprano
<(E-Mail Removed)> wrote:
> On Tue, 20 Dec 2011 15:45:07 -0500, Nathan Rice wrote:
>
>> If you take a moment and examine the version number, you will notice
>> that it is a date code.

>
> Not any date code I'm familiar with. 0.111220 doesn't look anything like
> a date to me.
>
> Possibly if the last release was two thousand years ago. I'd rather stick
> to actively maintained software, if it's all the same with you.


Date code != date.

>> In my opinion that is far more informative than
>> an arbitrary number. *I use the major version number to signify... Wait
>> for it... Major changes

>
> Well, that's one opinion. Another opinion is that nobody cares what
> specific day you release a new version, and that versions 0.191231 and
> 0.200101 probably aren't that big a difference.


Nobody cares about version numbers in general, except as a way to
fulfill dependencies. By using a date code, your versions are
guaranteed to sort in release order (which is nice, say if someone was
to download your software via FTP), you can tell what release has what
ticket fixes in an issue tracker, stuff like that. It also gives me
an easy way to be nostalgic about releases....

As for the extra "20" that I exclude, if I haven't updated the major
version number by the time 2020 rolls around I deserve any trouble it
causes
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      12-21-2011
On Tue, 20 Dec 2011 13:08:09 -0800, Paul Rubin wrote:

> Steven D'Aprano <(E-Mail Removed)> writes:
>> Not any date code I'm familiar with. 0.111220 doesn't look anything
>> like a date to me.

>
> 0 is the major version number. 111220 (the minor version number) is the
> date code, 2011-12-20 being today.


Not here it isn't. It is yesterday.


Writing-from-Down-Under-ly y'rs,

--
Steven
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      12-21-2011
On Tue, 20 Dec 2011 16:20:37 -0500, Nathan Rice wrote:

>> Well, that's one opinion. Another opinion is that nobody cares what
>> specific day you release a new version, and that versions 0.191231 and
>> 0.200101 probably aren't that big a difference.

>
> Nobody cares about version numbers in general, except as a way to
> fulfill dependencies. By using a date code, your versions are
> guaranteed to sort in release order (which is nice, say if someone was
> to download your software via FTP), you can tell what release has what
> ticket fixes in an issue tracker, stuff like that.


*blink*

It must be nice to have software with so few bugs that you can remember
the date you fixed each and every one just from the ticket number.


I don't actually care what version numbering scheme you use. I had just
never come across using part of a date as the version number before, and
I don't think that it is any more recognisable or sensible than any other
arbitrary numbering scheme. And it is arbitrary: the fact that you
happened to make a release on Tuesday rather than Wednesday doesn't have
any meaning (particularly if you're a night owl who is coding at
midnight) and yet you'll assign a different version number to it. To my
mind, the version number should encode (in some sense) the feature set,
not the date you release it.

It also has the serious disadvantage that you're limited to a single
release per day, unless you add an extra field to the version string.

But whatever floats your boat. I'm just glad that you've put your money
where your mouth is, and released the package, instead of demanding
others do the work. Thank you.


--
Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Elementwise 0.120116 -//- beta release -//- Lazily compute functions,method calls and operations on all elements of an iterable (or graph). Nathan Rice Python 0 01-16-2012 05:31 PM
Re: Elementwise -//- first release -//- Element-wise (vectorized)function, method and operator support for iterables in python. Nathan Rice Python 4 12-21-2011 04:43 PM
elementwise multiplication of 2 lists of numbers harryos Python 6 09-20-2010 04:33 PM
elementwise product or sum of two vectors er C++ 7 09-05-2007 09:14 AM
*expression and iterables Steven Bethard Python 0 08-20-2004 06:09 AM



Advertisments