Re: [Numpy-discussion] Inconsistent error messages.

2009-05-25 Thread Christopher Barker
Charles R Harris wrote: > I don't like the idea of a warning here either. How about adding a > keyword 'strict' so that strict=1 means an error is raised if the count > isn't reached, and strict=0 means any count is acceptable? I'd prefer a more meaningful name than "strict" -- you'd have absolu

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Charles R Harris
On Sat, May 23, 2009 at 6:37 PM, Eric Firing wrote: > Charles R Harris wrote: > > > > > > On Sat, May 23, 2009 at 6:03 PM, Robert Kern > > wrote: > > > > On Sat, May 23, 2009 at 18:57, Charles R Harris > > mailto:charlesr.har...@gmail.com>> > wrote: > >

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Stéfan van der Walt
2009/5/24 Eric Firing : >> OK, that would work. Although I think a named argument might be a more >> transparent way to specify behaviour than setting the warnings. > > I agree; using a warning strikes me as an abuse of the warnings > mechanism.  Instead of a "strict" flag, which I find not particu

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Eric Firing
Charles R Harris wrote: > > > On Sat, May 23, 2009 at 6:03 PM, Robert Kern > wrote: > > On Sat, May 23, 2009 at 18:57, Charles R Harris > mailto:charlesr.har...@gmail.com>> wrote: > > You were supposed to be able to change the default behaviour, but >

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Charles R Harris
On Sat, May 23, 2009 at 6:03 PM, Robert Kern wrote: > On Sat, May 23, 2009 at 18:57, Charles R Harris > wrote: > > You were supposed to be able to change the default behaviour, but it > didn't > > used to work. I think if you are going to use a warning as a flag then it > > has to always be rais

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Robert Kern
On Sat, May 23, 2009 at 18:57, Charles R Harris wrote: > You were supposed to be able to change the default behaviour, but it didn't > used to work. I think if you are going to use a warning as a flag then it > has to always be raised when a failure occurs, not just the first time. A brief test s

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Robert Kern
On Sat, May 23, 2009 at 18:57, Charles R Harris wrote: > > On Sat, May 23, 2009 at 5:51 PM, Robert Kern wrote: >> >> On Sat, May 23, 2009 at 18:43, Charles R Harris >> wrote: >> > Warnings used to warn once and then never again. I once hacked the >> > module to >> > make it work right but I don'

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Charles R Harris
On Sat, May 23, 2009 at 5:51 PM, Robert Kern wrote: > On Sat, May 23, 2009 at 18:43, Charles R Harris > wrote: > > Warnings used to warn once and then never again. I once hacked the module > to > > make it work right but I don't know if it has been officially fixed. Do > you > > know if it's bee

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Robert Kern
On Sat, May 23, 2009 at 18:43, Charles R Harris wrote: > Warnings used to warn once and then never again. I once hacked the module to > make it work right but I don't know if it has been officially fixed. Do you > know if it's been fixed? Warning once per location then never again is, and always

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Charles R Harris
2009/5/23 Stéfan van der Walt > Hi Chris and Charles > > 2009/5/23 Charles R Harris : > >> Robert thought that should be the default, but I think that means > >> everyone would be forced to check how many items they got every time > >> they read, which is too much code and likely to be forgotten

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Stéfan van der Walt
Hi Chris and Charles 2009/5/23 Charles R Harris : >> Robert thought that should be the default, but I think that means >> everyone would be forced to check how many items they got every time >> they read, which is too much code and likely to be forgotten and lead to >> errors. So I think that an e

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Charles R Harris
On Sat, May 23, 2009 at 2:02 PM, Christopher Barker wrote: > Stéfan van der Walt wrote: > > 2009/5/23 Charles R Harris : > >> In [9]: fromfile("empty.dat", count=10) > > > Instead of throwing errors in these scenarios, we could just return > > the elements read and raise a warning? This is consis

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Christopher Barker
Stéfan van der Walt wrote: > 2009/5/23 Charles R Harris : >> In [9]: fromfile("empty.dat", count=10) > Instead of throwing errors in these scenarios, we could just return > the elements read and raise a warning? This is consistent with most > other file APIs I know and allows you to read blocks o

Re: [Numpy-discussion] Inconsistent error messages.

2009-05-23 Thread Stéfan van der Walt
2009/5/23 Charles R Harris : > In [9]: fromfile("empty.dat", count=10) > 10 items requested but only 0 read > --- > MemoryError   Traceback (most recent call last) > > /home/charris/ in () > > Memory

[Numpy-discussion] Inconsistent error messages.

2009-05-22 Thread Charles R Harris
Hi All, Currently fromfile prints a message raises a MemoryError when more items are requested than read, but fromstring raises a value error: In [8]: fromstring("", count=10) --- ValueErrorTra