reshape is not working properly or i'm doing something wrong?

37 views
Skip to first unread message

Tiago Albineli Motta

unread,
Sep 14, 2017, 11:13:22 AM9/14/17
to Scala Breeze

This test is not passing:


    val dense = DenseMatrix(
        DenseVector(1D, 2D, 1D, 2D, 1D, 2D),
        DenseVector(3D, 4D, 3D, 4D, 3D, 4D))

    val reshaped = dense.reshape(6, 2)
    val expected = DenseMatrix(
        DenseVector(1D, 2D),
        DenseVector(1D, 2D),
        DenseVector(1D, 2D),
        DenseVector(3D, 4D),
        DenseVector(3D, 4D),
        DenseVector(3D, 4D))

    Assert.assertEquals(expected, reshaped)


Result in Breeze is:

1.0  2.0  
3.0  4.0  
2.0  1.0  
4.0  3.0  
1.0  2.0  
3.0  4.0


NumPy works fine:

>>> import numpy as np
>>> dense = np.array([[1,2,1,2,1,2], [3,4,3,4,3,4]])
>>> dense.reshape(6,2)
array([[1, 2],
       [1, 2],
       [1, 2],
       [3, 4],
       [3, 4],
       [3, 4]])


I'm using: org.scalanlp:breeze_2.11:0.13.2


I created this issue: https://github.com/scalanlp/breeze/issues/655


David Hall

unread,
Sep 15, 2017, 2:19:28 PM9/15/17
to scala-...@googlegroups.com
Sorry that I didn't unembargo this for so long. I think you got your answer on github.

If I were doing this over again, I'd do default row-major matrices, but that's too big of a change

--
You received this message because you are subscribed to the Google Groups "Scala Breeze" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-breeze+unsubscribe@googlegroups.com.
To post to this group, send email to scala-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scala-breeze/f1a4b445-8657-4dc6-82cd-c9459144ce37%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages