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

Anne Archibald peridot.faceted at gmail.com
Thu Apr 17 16:34:03 EDT 2008


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?

Anne



More information about the NumPy-Discussion mailing list