Re: [Numpy-discussion] request for new array method: arr.abs()
Travis Oliphant wrote: > I think I prefer to just add the float, bool, object, unicode, str names > to the "non-imported" numpy > name-space. which mean you get it with: import numpy as N N.float but not with from numpy import * ? If that's what you mean, then I'm all for it! -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
Christopher Barker wrote: > Travis Oliphant wrote: > > >> Instead, I like better the idea of adding abs, round, max, and min to >> the "non-import-*" namespace of numpy. >> > > Another I'd like is the built-in data types. I always use: > > import numpy as N > > so then I do: > > a = zeros(shape, float) > or > a = zeros(shape, N.float_) > > but for non-built-in types, I can't do the former. > > The underscore is minor but why not just have: > > float = float > > in numpy.py? > > (and of course, the others) > I think I prefer to just add the float, bool, object, unicode, str names to the "non-imported" numpy name-space. -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
Travis Oliphant wrote: > Instead, I like better the idea of adding abs, round, max, and min to > the "non-import-*" namespace of numpy. Another I'd like is the built-in data types. I always use: import numpy as N so then I do: a = zeros(shape, float) or a = zeros(shape, N.float_) but for non-built-in types, I can't do the former. The underscore is minor but why not just have: float = float in numpy.py? (and of course, the others) -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception [EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
Travis Oliphant wrote: > Sebastian Haase wrote: >> On Wednesday 23 August 2006 18:37, Travis Oliphant wrote: >> >>> David M. Cooke wrote: >>> On Wed, 23 Aug 2006 16:22:52 -0700 Sebastian Haase <[EMAIL PROTECTED]> wrote: > On Wednesday 23 August 2006 16:12, Bill Baxter wrote: > >> The thing that I find I keep forgetting is that abs() is a built-in, >> but other simple functions are not. So it's abs(foo), but >> numpy.floor(foo) and numpy.ceil(foo). And then there's round() which >> is a built-in but can't be used with arrays, so numpy.round_(foo). >> Seems like it would be more consistent to just add a numpy.abs() and >> numpy.round(). >> > Regarding the original subject: > a) "absolute" is impractically too much typing and > b) I just thought some (module-) functions might be "forgotten" to be > put in as (object-) methods ... !? > Four-line change, so I added a.abs() (three lines for array, one for MaskedArray). >>> While I appreciate it's proactive nature, I don't like this change >>> because it adds another "ufunc" as a method. Right now, I think conj is >>> the only other method like that. >>> >>> Instead, I like better the idea of adding abs, round, max, and min to >>> the "non-import-*" namespace of numpy. >>> >>> >> How does this compare with >> mean, min, max, average >> ? >> > > I'm not sure what this question is asking, so I'll answer what I think > it is asking. > > The mean, min, max, and average functions are *not* ufuncs. They are > methods of particular ufuncs. > Yes - that's what wanted to hear ! I'm just trying to bring in the "user's" point of view: Not thinking about how they are implemented under the hood: mean,min,max,average have a very similar "feeling" to them as "abs". I'm hoping this ("seeing things from the user p.o.v.") can stay like that for as long as possible ! Numpy should be focused on "scientist not programers". (This is just why I posted this comment about "arr.abs()" - but if there is a good reason to not have this for "simplicity reasons 'under the hood'" I can see that perfectly fine !) - Sebastian - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
Sebastian Haase wrote: > On Wednesday 23 August 2006 18:37, Travis Oliphant wrote: > >> David M. Cooke wrote: >> >>> On Wed, 23 Aug 2006 16:22:52 -0700 >>> >>> Sebastian Haase <[EMAIL PROTECTED]> wrote: >>> On Wednesday 23 August 2006 16:12, Bill Baxter wrote: > The thing that I find I keep forgetting is that abs() is a built-in, > but other simple functions are not. So it's abs(foo), but > numpy.floor(foo) and numpy.ceil(foo). And then there's round() which > is a built-in but can't be used with arrays, so numpy.round_(foo). > Seems like it would be more consistent to just add a numpy.abs() and > numpy.round(). > Regarding the original subject: a) "absolute" is impractically too much typing and b) I just thought some (module-) functions might be "forgotten" to be put in as (object-) methods ... !? >>> Four-line change, so I added a.abs() (three lines for array, one >>> for MaskedArray). >>> >> While I appreciate it's proactive nature, I don't like this change >> because it adds another "ufunc" as a method. Right now, I think conj is >> the only other method like that. >> >> Instead, I like better the idea of adding abs, round, max, and min to >> the "non-import-*" namespace of numpy. >> >> > How does this compare with > mean, min, max, average > ? > I'm not sure what this question is asking, so I'll answer what I think it is asking. The mean, min, max, and average functions are *not* ufuncs. They are methods of particular ufuncs. The abs() should not be slow (because it calls the __abs__ method which for arrays is mapped to the ufunc absolute). Thus, there is one more layer of indirection which will only matter for small arrays. -Travis - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
On Wednesday 23 August 2006 18:37, Travis Oliphant wrote: > David M. Cooke wrote: > > On Wed, 23 Aug 2006 16:22:52 -0700 > > > > Sebastian Haase <[EMAIL PROTECTED]> wrote: > >> On Wednesday 23 August 2006 16:12, Bill Baxter wrote: > >>> The thing that I find I keep forgetting is that abs() is a built-in, > >>> but other simple functions are not. So it's abs(foo), but > >>> numpy.floor(foo) and numpy.ceil(foo). And then there's round() which > >>> is a built-in but can't be used with arrays, so numpy.round_(foo). > >>> Seems like it would be more consistent to just add a numpy.abs() and > >>> numpy.round(). > >> > >> Regarding the original subject: > >> a) "absolute" is impractically too much typing and > >> b) I just thought some (module-) functions might be "forgotten" to be > >> put in as (object-) methods ... !? > > > > Four-line change, so I added a.abs() (three lines for array, one > > for MaskedArray). > > While I appreciate it's proactive nature, I don't like this change > because it adds another "ufunc" as a method. Right now, I think conj is > the only other method like that. > > Instead, I like better the idea of adding abs, round, max, and min to > the "non-import-*" namespace of numpy. > How does this compare with mean, min, max, average ? BTW: I think me choice is now settled on the builtin call: abs(arr) -- short and sweet. (As long as it is really supposed to *always* work and is not *slow* in any way !?!?!?!?) Cheers, Sebastian - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
David M. Cooke wrote: > On Wed, 23 Aug 2006 16:22:52 -0700 > Sebastian Haase <[EMAIL PROTECTED]> wrote: > > >> On Wednesday 23 August 2006 16:12, Bill Baxter wrote: >> >>> The thing that I find I keep forgetting is that abs() is a built-in, but >>> other simple functions are not. So it's abs(foo), but numpy.floor(foo) >>> and numpy.ceil(foo). And then there's round() which is a built-in but >>> can't be used with arrays, so numpy.round_(foo).Seems like it would >>> be more consistent to just add a numpy.abs() and numpy.round(). >>> >>> >> Regarding the original subject: >> a) "absolute" is impractically too much typing and >> b) I just thought some (module-) functions might be "forgotten" to be put >> in as (object-) methods ... !? >> > > Four-line change, so I added a.abs() (three lines for array, one > for MaskedArray). > While I appreciate it's proactive nature, I don't like this change because it adds another "ufunc" as a method. Right now, I think conj is the only other method like that. Instead, I like better the idea of adding abs, round, max, and min to the "non-import-*" namespace of numpy. - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
On 8/23/06, Bill Baxter <[EMAIL PROTECTED]> wrote: > The thing that I find I keep forgetting is that abs() is a built-in, but > other simple functions are not. So it's abs(foo), but numpy.floor(foo) and > numpy.ceil(foo). And then there's round() which is a built-in but can't be > used with arrays, so numpy.round_(foo).Seems like it would be more > consistent to just add a numpy.abs() and numpy.round(). > > But I guess there's nothing numpy can do about it... you can't name a > method the same as a built-in function, right? That's why we have > numpy.round_() instead of numpy.round(), no? > [...goes and checks] > Oh, you *can* name a module function the same as a built-in. Hmm... so then > why isn't numpy.round_() just numpy.round()? Is it just so "from numpy > import *" won't hide the built-in? Technically numpy could simply have (illustrated with round, but works also with abs) round = round_ and simply NOT include round in the __all__ list. This would make numpy.round(x) work (clean syntax) while from numpy import * would not clobber the builtin round. That sounds like a decent solution to me. Cheers, f - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
On Wed, 23 Aug 2006 16:22:52 -0700 Sebastian Haase <[EMAIL PROTECTED]> wrote: > On Wednesday 23 August 2006 16:12, Bill Baxter wrote: > > The thing that I find I keep forgetting is that abs() is a built-in, but > > other simple functions are not. So it's abs(foo), but numpy.floor(foo) > > and numpy.ceil(foo). And then there's round() which is a built-in but > > can't be used with arrays, so numpy.round_(foo).Seems like it would > > be more consistent to just add a numpy.abs() and numpy.round(). > > > > Regarding the original subject: > a) "absolute" is impractically too much typing and > b) I just thought some (module-) functions might be "forgotten" to be put > in as (object-) methods ... !? Four-line change, so I added a.abs() (three lines for array, one for MaskedArray). -- |>|\/|< /--\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |[EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
On Wednesday 23 August 2006 16:12, Bill Baxter wrote: > The thing that I find I keep forgetting is that abs() is a built-in, but > other simple functions are not. So it's abs(foo), but numpy.floor(foo) and > numpy.ceil(foo). And then there's round() which is a built-in but can't be > used with arrays, so numpy.round_(foo).Seems like it would be more > consistent to just add a numpy.abs() and numpy.round(). > > But I guess there's nothing numpy can do about it... you can't name a > method the same as a built-in function, right? That's why we have > numpy.round_() instead of numpy.round(), no? > [...goes and checks] > Oh, you *can* name a module function the same as a built-in. Hmm... so > then why isn't numpy.round_() just numpy.round()? Is it just so "from > numpy import *" won't hide the built-in? > That is my theory... Even tough I try to advertise import numpy as N a) "N." is not *that* much extra typing b) it much clearer to read code and see what is special from numpy vs. what is builtin c) (most important for me): I use PyShell/PyCrust and when I type the '.' after 'N' I get a nice pop-up list reminding me of all the function in numy ;-) Regarding the original subject: a) "absolute" is impractically too much typing and b) I just thought some (module-) functions might be "forgotten" to be put in as (object-) methods ... !? Cheers, Sebastian > --bill > > On 8/24/06, David M. Cooke <[EMAIL PROTECTED]> wrote: > > On Wed, 23 Aug 2006 13:51:02 -0700 > > > > Sebastian Haase <[EMAIL PROTECTED]> wrote: > > > Hi! > > > numpy renamed the *function* abs to absolute. > > > Most functions like mean, min, max, average, ... > > > have an equivalent array *method*. > > > > > > Why is absolute left out ? > > > I think it should be added . > > > > We've got __abs__ :-) > > > > > Furthermore, looking at some line of code that have multiple calls to > > > absolute [ like f(absolute(a), absolute(b), absolute(c)) ] > > > I think "some people" might prefer less typing and less reading, > > > like f( a.abs(), b.abs(), c.abs() ). > > > > > > One could even consider not requiring the "function call" parenthesis > > > > '()' > > > > > at all - but I don't know about further implications that might have. > > > > eh, no. things that return new arrays should be functions. (As opposed to > > views of existing arrays, like a.T) > > > > > PS: is there any performace hit in using the built-in abs function ? > > > > Shouldn't be: abs(x) looks for the x.__abs__() method (which arrays > > have). - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
The thing that I find I keep forgetting is that abs() is a built-in, but other simple functions are not. So it's abs(foo), but numpy.floor(foo) and numpy.ceil(foo). And then there's round() which is a built-in but can't be used with arrays, so numpy.round_(foo). Seems like it would be more consistent to just add a numpy.abs() and numpy.round().But I guess there's nothing numpy can do about it... you can't name a method the same as a built-in function, right? That's why we have numpy.round_() instead of numpy.round(), no?[...goes and checks]Oh, you *can* name a module function the same as a built-in. Hmm... so then why isn't numpy.round_() just numpy.round()? Is it just so "from numpy import *" won't hide the built-in? --billOn 8/24/06, David M. Cooke <[EMAIL PROTECTED]> wrote: On Wed, 23 Aug 2006 13:51:02 -0700Sebastian Haase <[EMAIL PROTECTED]> wrote:> Hi!> numpy renamed the *function* abs to absolute.> Most functions like mean, min, max, average, ... > have an equivalent array *method*.>> Why is absolute left out ?> I think it should be added .We've got __abs__ :-)> Furthermore, looking at some line of code that have multiple calls to > absolute [ like f(absolute(a), absolute(b), absolute(c)) ]> I think "some people" might prefer less typing and less reading,> like f( a.abs(), b.abs(), c.abs() ).> One could even consider not requiring the "function call" parenthesis '()' > at all - but I don't know about further implications that might have.eh, no. things that return new arrays should be functions. (As opposed toviews of existing arrays, like a.T)> PS: is there any performace hit in using the built-in abs function ? Shouldn't be: abs(x) looks for the x.__abs__() method (which arrays have). - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Re: [Numpy-discussion] request for new array method: arr.abs()
On Wed, 23 Aug 2006 13:51:02 -0700 Sebastian Haase <[EMAIL PROTECTED]> wrote: > Hi! > numpy renamed the *function* abs to absolute. > Most functions like mean, min, max, average, ... > have an equivalent array *method*. > > Why is absolute left out ? > I think it should be added . We've got __abs__ :-) > Furthermore, looking at some line of code that have multiple calls to > absolute [ like f(absolute(a), absolute(b), absolute(c)) ] > I think "some people" might prefer less typing and less reading, > like f( a.abs(), b.abs(), c.abs() ). > One could even consider not requiring the "function call" parenthesis '()' > at all - but I don't know about further implications that might have. eh, no. things that return new arrays should be functions. (As opposed to views of existing arrays, like a.T) > PS: is there any performace hit in using the built-in abs function ? Shouldn't be: abs(x) looks for the x.__abs__() method (which arrays have). -- |>|\/|< /--\ |David M. Cooke http://arbutus.physics.mcmaster.ca/dmc/ |[EMAIL PROTECTED] - Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 ___ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion