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] [Commented] (MAHOUT-1230) SparceMatrix.clone() is not deep copy
Date Mon, 27 May 2013 17:39:20 GMT

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

Ted Dunning commented on MAHOUT-1230:
-------------------------------------

Looks like a nice catch.

Shouldn't this test go in MatrixTest instead?

If so, then changing the test matrix to be bigger than 1x1 is helpful:
{code}
  @Test
  public void testClone() {
    double oldValue = 1.23;
    double newValue = 2.34;
    double[][] values = {{oldValue, 3}, {3, 5}, {7, 9}};
    Matrix matrix = matrixFactory(values);
    Matrix clone = matrix.clone();
    clone.set(0, 0, newValue);
    //test whether the update in the clone is reflected in the original matrix
    assertEquals("Matrix clone is not independent of the original",
      oldValue, matrix.get(0, 0), EPSILON);
  }
{code}
This uncovers the same problem in PivotMatrix.
                
> SparceMatrix.clone() is not deep copy
> -------------------------------------
>
>                 Key: MAHOUT-1230
>                 URL: https://issues.apache.org/jira/browse/MAHOUT-1230
>             Project: Mahout
>          Issue Type: Bug
>          Components: Math
>    Affects Versions: 0.7
>            Reporter: Maysam Yabandeh
>            Priority: Minor
>              Labels: test
>             Fix For: 0.7, 0.8
>
>         Attachments: MAHOUT-1230.patch
>
>
> After changing the matrix created by clone(), the original matrix changes as well. I
am attaching a patch with the unit test.

--
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

Mime
View raw message