naushad-rahman / ellipsoids

Automatically exported from code.google.com/p/ellipsoids
0 stars 0 forks source link

Cover @hyperplane class with unit tests #23

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You should crete elltool.core.test.mlunit package, 
it would be located in <YourWorkingCopy>\products\+elltool\+core\+test\+mlunit. 

In this package you should create HyperplaneTestCase MLUNITEXT test class, the 
name of the file would 
be  <YourWorkingCopy>\products\+elltool\+core\+test\+mlunit\HyperplaneTestCase.m

Along with this class you should 
 # create run_tests function in <YourWorkingCopy>\products\+elltool\+core\+test folder which 
would put it into elltool.core.test packet
 # Modify elltool.test.run_tests function so that it calls 
your newly created elltool.core.test.run_tests function in the way described in 
item 3 on 

http://code.google.com/p/ellipsoids/wiki/MLUNITEXT_unit_testing_framework_descri
ption 

Wiki page

Once all this is done you need to write unit tests for ALL the methods of 
@hyperplane class. This is a simple class 
so it should not be too hard. Please

The idea of a unit test is that you think of an analytical example where the 
output is known in advance and compare this 
expected output with the output produced by the function or/and method. 

Original issue reported on code.google.com by heartofm...@gmail.com on 19 Oct 2012 at 6:22

GoogleCodeExporter commented 9 years ago
Should i create a test for class constructor? And if i should, how can i access 
to the to the object's fields not from class methods?

Original comment by justente...@gmail.com on 23 Oct 2012 at 7:10

GoogleCodeExporter commented 9 years ago
Yes, you should - use other methods like double to extract the properties. But 
this test is not critical as in the tests for other methods you will call the 
constructor multiple times

Original comment by heartofm...@gmail.com on 23 Oct 2012 at 7:13

GoogleCodeExporter commented 9 years ago
Hyperplane methods double() and parameters() seem to duplicate each other. 

Original comment by justente...@gmail.com on 23 Oct 2012 at 8:30

GoogleCodeExporter commented 9 years ago
I merged with trunk, and after that some changes in lib/+modgen appeared. Is it 
normal? should i commit them?

Original comment by justente...@gmail.com on 26 Oct 2012 at 11:35

GoogleCodeExporter commented 9 years ago
Yes, these changes result from merge, without committing them the merge is 
useless because it just changes your local working copy. Just make sure that 
you merged with the working copy that doesn't contain any changes.

Original comment by heartofm...@gmail.com on 26 Oct 2012 at 1:05

GoogleCodeExporter commented 9 years ago
I've discovered, that hyperplane(V,C) constructor throws an error, when you 
give it V in R^(n x m) and vector C  in R^(m x 1). But it works properly, when 
C is in R^(1 x m). Is it a bug?
The description in hyperplane constructor:
HA = HYPERPLANE(V, C)  If V is matrix in R^(n x m) and C is array of numbers of 
length m or 1, then m hyperplane structures are created and returned in array 
HA.
The text of error, when m = 7:
ELL_HYPERPLANE: second argument must be a scalar, or an array of 7 scalars.

Original comment by justente...@gmail.com on 26 Oct 2012 at 4:15

GoogleCodeExporter commented 9 years ago
It is not a bug - hyperplane constructor is designed to create an array of 
hyperplane objects. For m=1 a single object is created, for m>1 - an array of 
objects. So it is logical that hyperplane makes sure that C and V have the same 
size (m) along the second dimension. This size represents a number of objects 
to create.

Btw - you should have changed a status of the ticket to "Started" based on our 
workflow policy.

Original comment by heartofm...@gmail.com on 26 Oct 2012 at 4:34

GoogleCodeExporter commented 9 years ago

Original comment by justente...@gmail.com on 26 Oct 2012 at 4:36

GoogleCodeExporter commented 9 years ago
I have some questions. First is should i write a negative tests for all 
possible exceptions? The second is about testing 'display' and the same 
methods. We need just run this method in our test an nothing else, am i right?

Original comment by justente...@gmail.com on 28 Oct 2012 at 10:03

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've a notification that you've left a comment for this ticket but I can't see 
it here... Have you deleted it? 
Anyways, answering your question
"I found, that we can create a hyperplane, that contains NaNs or Infs in normal 
vector or constant, shouldn't we forbid doing that?"
Yes, absolutely. Use modgen.common.type.simple.checkgenext function like that

import modgen.common.type.simple.checkgenext;
checkgen('any(isnan(x1))||any(isinf(x1))||isnan(x2)||isinf(x2)',2,hNormVector,hC
onst);

Original comment by heartofm...@gmail.com on 30 Oct 2012 at 2:33

GoogleCodeExporter commented 9 years ago
I found, that we can create a hyperplane, that contains NaNs or Infs in normal 
vector or constant, shouldn't we forbid doing that? Also how do we need to 
threat with vectors, that have Inf components in contains(.,.) operation? 

Original comment by justente...@gmail.com on 30 Oct 2012 at 2:37

GoogleCodeExporter commented 9 years ago
That's easy - if the corresponding components in the hyperplane normal vector 
are zero then you just calculate a scalar product of x and hNormalVec using the 
remaining components. Otherwise contains should return false. 

Original comment by heartofm...@gmail.com on 30 Oct 2012 at 2:45

GoogleCodeExporter commented 9 years ago
I can't catch the exception from modgen.common.type.simple.checkgenext while 
running runAndCheckError. if you can, see HyperplaneTestCase class commented 
method testWrongInput. What am I doing wrong?

Original comment by justente...@gmail.com on 30 Oct 2012 at 8:37

GoogleCodeExporter commented 9 years ago
The thing is that runAndCheckError's second argument is an exception identifier 
while the error message is the third argument. Also, checking for an exact 
error message is an overkill, I would skip the third argument (error message) 
altogether for this kind of testing.

Original comment by heartofm...@gmail.com on 30 Oct 2012 at 8:52

GoogleCodeExporter commented 9 years ago
One more thing:

You can actually check for a presence of certain markers in the error message 
like that

            self.runAndCheckError('hyperplane(infVector,testConstant)',...
                'wrongInput',...
                'v,c ');

it is not necessary to specify a complete error message, just specify some 
substring that would help to make sure that the message is the one you expect.

Original comment by heartofm...@gmail.com on 30 Oct 2012 at 8:55

GoogleCodeExporter commented 9 years ago
Your branch is ready for reintegration.

Just wait for Vitaly Baranov to finish his reintegration (he was given a signal 
just 30 minutes ago.

Please follow the steps of reintegration algorithm described at 
http://code.google.com/p/ellipsoids/wiki/Issues_workflow_and_branching_policy

Original comment by heartofm...@gmail.com on 1 Nov 2012 at 7:21

GoogleCodeExporter commented 9 years ago
Please do reintegrate ASAP so that I can close the ticket. Thanks.

Original comment by heartofm...@gmail.com on 2 Nov 2012 at 8:56

GoogleCodeExporter commented 9 years ago

Original comment by heartofm...@gmail.com on 2 Dec 2012 at 1:20