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

Sean Owen resolved SPARK-17130.
-------------------------------
    Resolution: Duplicate

Oh yeah but along the way the validation is also all moved into the 
constructor. That was actually the last comment on the PR -- sorry thought 
that's what you saw and were even responding to. See 
https://github.com/apache/spark/pull/14555/files#diff-84f492e3a9c1febe833709960069b1b2R553
  I think the issue was that Vectors.sparse does validate but new 
SparseVector() does not? well, both will be validated now. I'll say this is a 
duplicate because we should definitely resolve both at once.

> SparseVectors.apply and SparseVectors.toArray have different returns when 
> creating with a illegal indices
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: SPARK-17130
>                 URL: https://issues.apache.org/jira/browse/SPARK-17130
>             Project: Spark
>          Issue Type: Bug
>          Components: ML, MLlib
>    Affects Versions: 1.6.2, 2.0.0
>         Environment: spark 1.6.1 + scala
>            Reporter: Jon Zhong
>            Priority: Minor
>
> One of my colleagues ran into a bug of SparseVectors. He called the 
> Vectors.sparse(size: Int, indices: Array[Int], values: Array[Double]) without 
> noticing that the indices are assumed to be ordered.
> The vector he created has all value of 0.0 (without any warning), if we try 
> to get value via apply method. However, SparseVector.toArray will generates a 
> array using a method that is order insensitive. Hence, you will get a 0.0 
> when you call apply method, while you can get correct result using toArray or 
> toDense method. The result of SparseVector.toArray is actually misleading.
> It could be safer if there is a validation of indices in the constructor or 
> at least make the returns of apply method and toArray method the same.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to