[ 
https://issues.apache.org/jira/browse/MAHOUT-1091?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13472599#comment-13472599
 ] 

Ted Dunning commented on MAHOUT-1091:
-------------------------------------

For instance, this test:
{code}
    public void testIterators() {
      final T v0 = vectorToTest(20);

      double sum = 0;
      int elements = 0;
      int nonZero = 0;
      for (Vector.Element element : v0) {
        elements++;
        sum += element.get();
        if (element.get() != 0) {
          nonZero++;
        }
      }
  
      int nonZeroIterated = 0;
      final Iterator<Vector.Element> i = v0.iterateNonZero();
      while (i.hasNext()) {
        i.next();
        nonZeroIterated++;
      }
      assertEquals(20, elements);
      assertEquals(v0.size(), elements);
      assertEquals(nonZeroIterated, nonZero);
      assertEquals(v0.zSum(), sum, 0);
    }
{code}
Note how the iteration test verifies that it sees all the elements, but sees 
only the non-zeros in the non-zero iteration.
                
> Bug in SequentialAccessSparseVector full iteration
> --------------------------------------------------
>
>                 Key: MAHOUT-1091
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-1091
>             Project: Mahout
>          Issue Type: Bug
>          Components: Math
>            Reporter: Ted Dunning
>             Fix For: 0.8
>
>         Attachments: 
> 0001-MAHOUT-1091-Add-test-to-demonstrate-broken-iterator-.patch, 
> 0001-MAHOUT-1091-Add-test-to-demonstrate-broken-iterator-.patch, 
> MAHOUT-1091.patch
>
>
> The iterator for the SequentialAccessSparseVector doesn't return any items 
> beyond the last non-zero.  This breaks some stuff pretty massively, but 
> hopefully doesn't break much user code since iterating through all elements 
> of a sparse vector is a relatively rare thing to do.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to