[Numpy-discussion] broken numpy.core.tests.test_multiarray.TestScalarIndexing.SetUp

Robert Kern robert.kern at gmail.com
Thu Apr 17 16:53:04 EDT 2008


On Thu, Apr 17, 2008 at 3:34 PM, Anne Archibald
<peridot.faceted at gmail.com> wrote:
> On 17/04/2008, Robert Kern <robert.kern at gmail.com> wrote:
>  > On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <efiring at hawaii.edu> wrote:
>  >  > Arg!  Cancel that!  I didn't look carefully enough.  How embarrassing!
>  >  >  Sorry for the noise.
>  >
>  > Don't apologize. That is very odd code. Stefan, is there a reason to
>  >  form a 1-item tuple then do 1-item tuple unpacking everywhere? The
>  >  test works the same after removing the extraneous commas. Anyways,
>  >  I've checked that in.
>
>  This is not necessarily a justification, but many tests construct
>  tuples of test objects which are then unpacked at the beginning of
>  every function. This is not unreasonable when multiple objects are
>  present:
>
>  class TestSomething(NumpyTestCase):
>     def setUp(self):
>         A = array([1,2,3])
>         B = array([4,5,6])
>         self.d = A, B
>
>     def test_something(self):
>         A, B = self.d
>         assert_not_equal(A,B)
>
>  It's a little less cumbersome than using self.A and self.B inside each
>  test case.
>
>  Does it make sense to use a length-1 tuple when there's only one piece
>  of test data, just for consistency?

I don't think so. A trailing comma is too easy to miss and looks like
an error when it isn't missed.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
 -- Umberto Eco



More information about the NumPy-Discussion mailing list