← Back to team overview

larry-discuss team mailing list archive

Re: [Blueprint simplify-unit-testing] Create a larry specific assert function to simplify unit testing

 

On Wed, Feb 3, 2010 at 9:54 PM,  <josef.pktd@xxxxxxxxx> wrote:
> On Wed, Feb 3, 2010 at 9:16 PM, Keith Goodman <kwgoodman@xxxxxxxxx> wrote:
>> On Wed, Feb 3, 2010 at 6:06 PM, joep <josef.pktd@xxxxxxxxx> wrote:
>>> Blueprint changed by joep:
>>>
>>> Whiteboard set to:
>>>
>>> assert_larry
>>> http://bazaar.launchpad.net/~kwgoodman/larry/trunk/annotate/head%3A/la/tests/deflarry_nose_test.py#L49
>>>
>>> and the method check_function in test class
>>>
>>> http://bazaar.launchpad.net/~kwgoodman/larry/trunk/annotate/head%3A/la/tests/deflarry_nose_test.py#L128
>>>
>>> already contain the extracted boiler plate assert function to compare a
>>> larry with desired data matrix x and labels
>>>
>>> the later has a view keyword to choose whether to verify nocopy or
>>> noreference
>>>
>>> used in nosetests for larry methods
>>
>> I moved this to the larry-discuss list since it is hard to discuss it
>> through the whiteboard on the blueprint.
>>
>> Yes, let's start with those functions and then prettify them.
>>
>> What should the signature be?
>>
>> The current signature is:
>>
>> assert_larry(opname, la, t, lab, msgstr)
>>
>> How about changing that to the same signature as np.testing.assert_equal? So:
>>
>> assert_equal(actual, desired, err_msg='', verbose=True)
>>
>> Then we don't have to separate the data and the label. And instead of
>> nancode we can use the numpy nan aware assert in numpy 1.4.
>>
>> Oops...dinner time!
>
> I'm just browsing the code and adding some notes.
>
> Yes, matching the numpy signature for assert_equal and
> assert_almost_equal is a good idea.
> If you require numpy 1.4 for the test suite, then most of the boiler
> plate is gone (nan handling)
>
> I think that assert_larry_equal is equivalent to
> assert_equal(la1.x, la2.x)
> assert_equal(la1.label, la2.label)
>
> slicing_test.py/test_slicing and test_morph use directly an assert_
> which could be replaced by np.testing.assert_equal

just another comment:

there are 3 patterns in the test suite corresponding to the previous comments

* python unittest with boilerplate
* numpy 1.3 nosetests with explicit nan handling
* numpy 1.4 nosetests where numpy.testing assert do the nan handling

In the 4th option an explicit function assert_larry_xxx is not really
necessary, and the test for x and labels and nocopy/noreference could
also be "yielded" directly from the test function/method.

> Josef
>
>>
>> _______________________________________________
>> Mailing list: https://launchpad.net/~larry-discuss
>> Post to     : larry-discuss@xxxxxxxxxxxxxxxxxxx
>> Unsubscribe : https://launchpad.net/~larry-discuss
>> More help   : https://help.launchpad.net/ListHelp
>>
>



Follow ups

References