mahout-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Dunning (JIRA)" <j...@apache.org>
Subject [jira] Updated: (MAHOUT-489) SequentialAccessSparseVector iterators skip items
Date Fri, 27 Aug 2010 20:57:53 GMT

     [ https://issues.apache.org/jira/browse/MAHOUT-489?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Ted Dunning updated MAHOUT-489:
-------------------------------

    Status: Patch Available  (was: Open)

This test should fail until the patch is updated with a fix.

> SequentialAccessSparseVector iterators skip items
> -------------------------------------------------
>
>                 Key: MAHOUT-489
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-489
>             Project: Mahout
>          Issue Type: Bug
>          Components: Math
>            Reporter: Laszlo Dosa
>         Attachments: MAHOUT-489.patch
>
>
> The following test cases fail, which iterates through the elements of the SequentialAccessSparseVector,
because not every value is given back.
> SequentialAccessSparseVector.iterator() skips the last element, while the SequentialAccessSparseVector.iterateNonZero()
skips the first element.
> int [] index = new int[] { 0, 1, 2, 3, 4, 5 };
> int [] values = new int[] { 0, 1, 2, 3, 4, 5 };
> SequentialAccessSparseVector vector;
> @Before
> public void setUp() {
> 	vector = new SequentialAccessSparseVector(6);
> 	for(int i = 0; i < Math.min(index.length, values.length); i++ ) {
> 		vector.set(index[i], values[i]);
> 	}
> }
> @Test
> public void testIteratorAll() {
> 	int elements = 0;
> 	Iterator<Element> it = vector.iterator();
> 	while (it.hasNext()) {
> 		System.out.println(it.next().get());
> 		elements++;
> 	}
> 	assertEquals((int)vector.get(Math.min(index.length,values.length)-1),values[Math.min(index.length,
values.length)-1]);
> 	assertEquals(Math.min(index.length, values.length),elements);
> }
> @Test
> public void testIteratorNonNull() {
> 	int elements = 0;
> 	Iterator<Element> it = vector.iterateNonZero();
> 	while (it.hasNext()) {
> 		System.out.println(it.next().get());
> 		elements++;
> 	}
> 	assertEquals((int)vector.get(Math.min(index.length,values.length)-1),values[Math.min(index.length,
values.length)-1]);
> 	assertEquals(Math.min(index.length,values.length),elements);  
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message