[Numpy-discussion] ANN: NumPy 1.2.0

Charles R Harris charlesr.harris at gmail.com
Mon Sep 29 15:01:56 EDT 2008


On Mon, Sep 29, 2008 at 12:43 PM, Francesc Alted <faltet at pytables.org>wrote:

> A Monday 29 September 2008, Charles R Harris escrigué:
> > On Mon, Sep 29, 2008 at 11:50 AM, Robert Kern <robert.kern at gmail.com>
> wrote:
> > > On Mon, Sep 29, 2008 at 12:40, Charles R Harris
> > >
> > > <charlesr.harris at gmail.com> wrote:
> > > > On Mon, Sep 29, 2008 at 11:35 AM, Robert Kern
> > > > <robert.kern at gmail.com>
> > >
> > > wrote:
> > > >> On Mon, Sep 29, 2008 at 12:30, Charles R Harris
> > > >>
> > > >> <charlesr.harris at gmail.com> wrote:
> > > >> > On Mon, Sep 29, 2008 at 11:27 AM, Robert Kern
> > > >> > <robert.kern at gmail.com>
> > > >> >
> > > >> > wrote:
> > > >> >> When is -OO ever used for running tests? The assert statement
> > > >> >> is used for tests under nose.
> > > >> >
> > > >> > When it is the default on windows platforms. There was a
> > > >> > ticket..
> > > >>
> > > >> I see #893, which talks about when -OO is used explicitly and
> > > >> when numpy is part of a py2exe application. This does not refer
> > > >> to any default configuration on Windows platforms.
> > > >
> > > > Let's put it this way, if the tests were consistent with assert
> > > > then they couldn't be run with the -OO option. If they *can* be
> > > > run with the -OO option then they had better run correctly.
> > >
> > > I'm afraid that I don't understand what you are referring to.
> >
> > Asserts are transparent. If they go away, programs containing asserts
> > should still run correctly. It's like bounds checking in array
> > references, say in the std::vector class. If compiled with -DNODEBUG,
> > the programs still run. Programs shouldn't use asserts for
> > non-debugging purposes, they should raise real exceptions. If you
> > think the numpy tests are essentially debugging tests, then they
> > should all disappear when run with the -OO option, i.e., nose should
> > do nothing. If nose wants to make that change, that is fine with me.
> > But as is, incorrect failures may be reported and that is an error.
>
> Plain assert clauses used to be the most common way to check for test
> units in the original "unittest" module.  Later on, the authors started
> to introduce things like self.assert_() and family and warned that the
> use of the "assert" clause should be avoided (maybe thinking about
> possible changes in semantics inside Python itself, maybe thinking
> about the use of -OO).
>
> But I agree with Robert Kern that tests *should* never be run under -OO
> because they are *tests*, not production code, and using the -OO for
> running the test units is simply a wrong practice.
>

What if someone abuses assert in production code, how are you going to catch
that without using -OO? Assert abuse seems to be a common bug...

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080929/3ae296f0/attachment.html>


More information about the NumPy-Discussion mailing list