broken numpy.core.tests.test_multiarr


broken numpy.core.tests.test_multiarr

While trying to figure out how to write tests for "take", I stumbled
across this in numpy.core.tests.test_multiarray.py: class TestScalarIndexing(NumpyTestCase): def setUp(self): self.d = array([0,1])[0], def check_ellipsis_subscript(self): a, = self.d self.failUnlessEqual(a[...], 0) self.failUnlessEqual(a[...].shape,()) setUp is clearly broken, but the numpy test suite still runs happily. This seems odd. Eric _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
Arg! Cancel that! I didn't look carefully enough. How embarrassing!
Sorry for the noise. Eric Eric Firing wrote: > While trying to figure out how to write tests for "take", I stumbled > across this in numpy.core.tests.test_multiarray.py: > > class TestScalarIndexing(NumpyTestCase): > def setUp(self): > self.d = array([0,1])[0], > > def check_ellipsis_subscript(self): > a, = self.d > self.failUnlessEqual(a[...], 0) > self.failUnlessEqual(a[...].shape,()) > > > setUp is clearly broken, but the numpy test suite still runs happily. > This seems odd. > > Eric > _______________________________________________ > Numpydiscussion mailing list > [hidden email] > http://projects.scipy.org/mailman/listinfo/numpydiscussion _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <[hidden email]> 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 1item tuple then do 1item tuple unpacking everywhere? The test works the same after removing the extraneous commas. Anyways, I've checked that in.  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 _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
On 17/04/2008, Robert Kern <[hidden email]> wrote:
> On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <[hidden email]> 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 1item tuple then do 1item 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 length1 tuple when there's only one piece of test data, just for consistency? Anne _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
On Thu, Apr 17, 2008 at 3:34 PM, Anne Archibald
<[hidden email]> wrote: > On 17/04/2008, Robert Kern <[hidden email]> wrote: > > On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <[hidden email]> 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 1item tuple then do 1item 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 length1 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 _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
In reply to this post by Robert Kern2
On 17/04/2008, Robert Kern <[hidden email]> wrote:
> On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <[hidden email]> 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 1item tuple then do 1item tuple unpacking everywhere? Did I write that code? I agree that formatting is odd. Cheers Stéfan _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
On Thu, Apr 17, 2008 at 5:40 PM, Stéfan van der Walt <[hidden email]> wrote:
> On 17/04/2008, Robert Kern <[hidden email]> wrote: > > > On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <[hidden email]> 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 1item tuple then do 1item tuple unpacking everywhere? > > Did I write that code? I agree that formatting is odd. Sorry, I just looked at svn blame rather than the log message which states that you just checked in Anne's patch.  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 _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
In reply to this post by Stéfan van der Walt
On 17/04/2008, Stéfan van der Walt <[hidden email]> wrote:
> On 17/04/2008, Robert Kern <[hidden email]> wrote: > > > On Thu, Apr 17, 2008 at 1:21 PM, Eric Firing <[hidden email]> 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 1item tuple then do 1item tuple unpacking everywhere? > > > Did I write that code? I agree that formatting is odd. Oh! Actually I think that one's my fault. Comes of being too minimal in modifying one of your test cases. Anne _______________________________________________ Numpydiscussion mailing list [hidden email] http://projects.scipy.org/mailman/listinfo/numpydiscussion 
Free forum by Nabble  Edit this page 