Re: None versus MISSING sentinel -- request for design feedback

2011-07-16 Thread Ethan Furman
Gregory Ewing wrote: Ethan Furman wrote: some of the return values (Logical, Date, DateTime, and probably Character) will have their own dedicated singletons (Null, NullDate, NullDateTime, NullChar -- which will all compare equal to None) That doesn't seem like a good idea to me. It's common

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Gregory Ewing
Ethan Furman wrote: some of the return values (Logical, Date, DateTime, and probably Character) will have their own dedicated singletons (Null, NullDate, NullDateTime, NullChar -- which will all compare equal to None) That doesn't seem like a good idea to me. It's common practice to use 'is'

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Terry Reedy
On 7/15/2011 6:19 AM, Steven D'Aprano wrote: Use None as default. Requiring users to use your special value would be a nuisance. They may have data prepared separately from your module. Rob Williscroft wrote: MISSING = MissingObject() def mean( sequence, missing = MISSING ): This is also

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread OKB (not okblacke)
Steven D'Aprano wrote: > Rob Williscroft wrote: >> MISSING = MissingObject() >> def mean( sequence, missing = MISSING ): > > So you think the right API is to allow the caller to specify what > counts as a missing value at runtime? Are you aware of any other > statistics packages that do that?

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Ethan Furman
Mel wrote: Steven D'Aprano wrote: Well yes, but None is an explicit missing value too. The question I have is if I should support None as that value, or something else. Or if anyone can put a good case for it, both, or neither and so something completely different. If it's any help, I think (

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Eric Snow
On Thu, Jul 14, 2011 at 11:28 PM, Steven D'Aprano wrote: > Hello folks, > > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should be just ignored. E.g.: > > mean([1, 2,

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Mel
Steven D'Aprano wrote: > Well yes, but None is an explicit missing value too. The question I have > is if I should support None as that value, or something else. Or if anyone > can put a good case for it, both, or neither and so something completely > different. If it's any help, I think (some of

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Chris Angelico wrote: > On Fri, Jul 15, 2011 at 8:46 PM, Steven D'Aprano > wrote: >> In general, you have missing values in statistics because somebody >> wouldn't answer a question, and the Ethics Committee frowns on >> researchers torturing their subjects to get information. They make you >> fi

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Chris Angelico
On Fri, Jul 15, 2011 at 8:46 PM, Steven D'Aprano wrote: > In general, you have missing values in statistics because somebody wouldn't > answer a question, and the Ethics Committee frowns on researchers torturing > their subjects to get information. They make you fill out forms. > Which, then, is

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Teemu Likonen
* 2011-07-15T03:02:11-07:00 * bruno wrote: > On Jul 15, 10:28 am, Teemu Likonen wrote: >> How about accepting anything but ignoring all non-numbers? > > Totally unpythonic. Better to be explicit about what you expect and > crash as loudly as possible when you get anything unexpected. Sure, but s

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Chris Angelico wrote: > On Fri, Jul 15, 2011 at 3:28 PM, Steven D'Aprano > wrote: >> My question is, should I accept None as the missing value, or a dedicated >> singleton? >> >> In favour of None: it's already there, no extra code required. People may >> expect it to work. >> >> Against None: it

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Cameron Simpson
On 15Jul2011 20:17, Steven D'Aprano wrote: | Cameron Simpson wrote: | > I suppose there's no scope for having the append-to-the-list step sanity | > check for the sentinel (be it None or otherwise)? | | It is not my responsibility to validate data during construction, only to do | the right thin

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Rob Williscroft wrote: > Steven D'Aprano wrote in news:4e1fd009$0$29986$c3e8da3 > $54964...@news.astraweb.com in gmane.comp.python.general: > >> I'm designing an API for some lightweight calculator-like statistics >> functions, such as mean, standard deviation, etc., and I want to support >> miss

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Steven D'Aprano
Cameron Simpson wrote: > On 15Jul2011 15:28, Steven D'Aprano > wrote: > | In favour of None: it's already there, no extra code required. People > | may expect it to work. > > Broadly, I like this one for the reasons you cite. > > | Against None: it's too easy to mistakenly add None to a data se

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 10:28 am, Teemu Likonen wrote: > > How about accepting anything but ignoring all non-numbers? Totally unpythonic. Better to be explicit about what you expect and crash as loudly as possible when you get anything unexpected. -- http://mail.python.org/mailman/listinfo/python-list

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 9:44 am, Cameron Simpson wrote: > On 15Jul2011 15:28, Steven D'Aprano > wrote: > | Against MISSING: users may expect to be able to choose their own sentinel by > | assigning to MISSING. I don't want to support that. > > Well, we don't have readonly values to play with :-( > Personally

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Teemu Likonen
* 2011-07-15T15:28:41+10:00 * Steven D'Aprano wrote: > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to > support missing values. Missing values should be just ignored. E.g.: > > mean([1, 2, MISSING, 3]) => 6/3

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 7:28 am, Steven D'Aprano wrote: > > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should be just ignored. E.g.: (snip) > Against None: it's too easy to m

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread bruno.desthuilli...@gmail.com
On Jul 15, 8:08 am, Chris Angelico wrote: > > Agreed that float('nan') and "" and "spam" are all bad values for > Missings. Possibly "" should come out as 0 "In the face of ambiguity, refuse the temptation to guess." As far as I'm concerned, I'd expect this to raise a TypeError... -- http://m

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Rob Williscroft
Steven D'Aprano wrote in news:4e1fd009$0$29986$c3e8da3 $54964...@news.astraweb.com in gmane.comp.python.general: > I'm designing an API for some lightweight calculator-like statistics > functions, such as mean, standard deviation, etc., and I want to support > missing values. Missing values should

Re: None versus MISSING sentinel -- request for design feedback

2011-07-15 Thread Cameron Simpson
On 15Jul2011 15:28, Steven D'Aprano wrote: | In favour of None: it's already there, no extra code required. People may | expect it to work. Broadly, I like this one for the reasons you cite. | Against None: it's too easy to mistakenly add None to a data set by mistake, | because functions retur

Re: None versus MISSING sentinel -- request for design feedback

2011-07-14 Thread Chris Angelico
On Fri, Jul 15, 2011 at 3:28 PM, Steven D'Aprano wrote: > My question is, should I accept None as the missing value, or a dedicated > singleton? > > In favour of None: it's already there, no extra code required. People may > expect it to work. > > Against None: it's too easy to mistakenly add None

None versus MISSING sentinel -- request for design feedback

2011-07-14 Thread Steven D'Aprano
Hello folks, I'm designing an API for some lightweight calculator-like statistics functions, such as mean, standard deviation, etc., and I want to support missing values. Missing values should be just ignored. E.g.: mean([1, 2, MISSING, 3]) => 6/3 = 2 rather than 6/4 or raising an error. My ques