[jira] [Commented] (FLINK-1937) Cannot create SparseVector with only one non-zero element.

2015-05-07 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-1937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14532688#comment-14532688
 ] 

ASF GitHub Bot commented on FLINK-1937:
---

Github user asfgit closed the pull request at:

https://github.com/apache/flink/pull/636


 Cannot create SparseVector with only one non-zero element.
 --

 Key: FLINK-1937
 URL: https://issues.apache.org/jira/browse/FLINK-1937
 Project: Flink
  Issue Type: Bug
  Components: Machine Learning Library
Reporter: Chiwan Park
Assignee: Till Rohrmann
  Labels: ML

 I tried creating SparseVector with only one non-zero element. But I couldn't 
 create it. Following code causes the problem.
 {code}
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 {code}
 I got a compile error following:
 {code:none}
 Error:(60, 29) overloaded method value fromCOO with alternatives:
   (size: Int,entries: Iterable[(Int, 
 Double)])org.apache.flink.ml.math.SparseVector and
   (size: Int,entries: (Int, Double)*)org.apache.flink.ml.math.SparseVector
  cannot be applied to (Int, (Int, Int))
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 ^
 {code}



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


[jira] [Commented] (FLINK-1937) Cannot create SparseVector with only one non-zero element.

2015-04-28 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-1937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14517158#comment-14517158
 ] 

ASF GitHub Bot commented on FLINK-1937:
---

Github user chiwanpark commented on the pull request:

https://github.com/apache/flink/pull/636#issuecomment-97100649
  
Looks good to merge. :)


 Cannot create SparseVector with only one non-zero element.
 --

 Key: FLINK-1937
 URL: https://issues.apache.org/jira/browse/FLINK-1937
 Project: Flink
  Issue Type: Bug
  Components: Machine Learning Library
Reporter: Chiwan Park
Assignee: Till Rohrmann
  Labels: ML

 I tried creating SparseVector with only one non-zero element. But I couldn't 
 create it. Following code causes the problem.
 {code}
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 {code}
 I got a compile error following:
 {code:none}
 Error:(60, 29) overloaded method value fromCOO with alternatives:
   (size: Int,entries: Iterable[(Int, 
 Double)])org.apache.flink.ml.math.SparseVector and
   (size: Int,entries: (Int, Double)*)org.apache.flink.ml.math.SparseVector
  cannot be applied to (Int, (Int, Int))
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 ^
 {code}



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


[jira] [Commented] (FLINK-1937) Cannot create SparseVector with only one non-zero element.

2015-04-28 Thread Till Rohrmann (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-1937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14516699#comment-14516699
 ] 

Till Rohrmann commented on FLINK-1937:
--

Hi [~chiwanpark],

the problem here is that the Scala type inference mechanism cannot infer that 
the tuple type should be (Int, Double) instead of (Int, Int). When you provide 
multiple tuples to the {{fromCOO}} method, Scala knows that only the varargs 
method can be applied and thus concludes that the second field of each tuple 
has to be a {{Double}}. In case of a single tuple, I assume that Scala also 
considers the overloaded method which takes an {{Iterable}}.

You can circumvent this problem by simply telling Scala that your tuple is of 
type (Int, Double) by:
{code}
SparseVector.fromCOO(3, (1, 1.0))
{code}

We can also think of adding a special case {{fromCOO}} implementation which 
takes a single (Int, Int) tuple and converts it into (Int, Double).

 Cannot create SparseVector with only one non-zero element.
 --

 Key: FLINK-1937
 URL: https://issues.apache.org/jira/browse/FLINK-1937
 Project: Flink
  Issue Type: Bug
  Components: Machine Learning Library
Reporter: Chiwan Park
Assignee: Till Rohrmann
  Labels: ML

 I tried creating SparseVector with only one non-zero element. But I couldn't 
 create it. Following code causes the problem.
 {code}
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 {code}
 I got a compile error following:
 {code:none}
 Error:(60, 29) overloaded method value fromCOO with alternatives:
   (size: Int,entries: Iterable[(Int, 
 Double)])org.apache.flink.ml.math.SparseVector and
   (size: Int,entries: (Int, Double)*)org.apache.flink.ml.math.SparseVector
  cannot be applied to (Int, (Int, Int))
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 ^
 {code}



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


[jira] [Commented] (FLINK-1937) Cannot create SparseVector with only one non-zero element.

2015-04-28 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-1937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14516703#comment-14516703
 ] 

ASF GitHub Bot commented on FLINK-1937:
---

GitHub user tillrohrmann opened a pull request:

https://github.com/apache/flink/pull/636

[FLINK-1937] [ml] Fixes sparse vector/matrix creation fromCOO with a single 
element

The problem seems to be that Scala apparently cannot infer the correct type 
of a single tuple in the presence of the overloaded method with the 
```Iterable``` type parameter. If one provides more than one element, then 
Scala knows that only the varargs method is applicable and thus infers that the 
tuples have to be of type ```(Int, Double)```.

One can solve this problem by specifying explicitly that the single tuple 
is of type ```(Int, Double)```. However, to ensure a nice user experience I 
added a special case method which takes a single tuple of type ```(Int, Int)``` 
and converts it into a ```(Int, Double)``` type.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/tillrohrmann/flink fixSparseVector

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/flink/pull/636.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #636


commit 2a497a3e42574f5f17e4ec2133b8b7f7ccdd37bb
Author: Till Rohrmann trohrm...@apache.org
Date:   2015-04-28T09:01:07Z

[FLINK-1937] [ml] Fixes sparse vector/matrix creation fromCOO with a single 
element




 Cannot create SparseVector with only one non-zero element.
 --

 Key: FLINK-1937
 URL: https://issues.apache.org/jira/browse/FLINK-1937
 Project: Flink
  Issue Type: Bug
  Components: Machine Learning Library
Reporter: Chiwan Park
Assignee: Till Rohrmann
  Labels: ML

 I tried creating SparseVector with only one non-zero element. But I couldn't 
 create it. Following code causes the problem.
 {code}
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 {code}
 I got a compile error following:
 {code:none}
 Error:(60, 29) overloaded method value fromCOO with alternatives:
   (size: Int,entries: Iterable[(Int, 
 Double)])org.apache.flink.ml.math.SparseVector and
   (size: Int,entries: (Int, Double)*)org.apache.flink.ml.math.SparseVector
  cannot be applied to (Int, (Int, Int))
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 ^
 {code}



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


[jira] [Commented] (FLINK-1937) Cannot create SparseVector with only one non-zero element.

2015-04-27 Thread Till Rohrmann (JIRA)

[ 
https://issues.apache.org/jira/browse/FLINK-1937?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=14514095#comment-14514095
 ] 

Till Rohrmann commented on FLINK-1937:
--

Hi [~chiwanpark],

the problem is that you're giving a tuple of (Int, Int) to the function 
{{fromCOO}} which expects a tuple of (Int, Double). Creating the 
{{SparseVector}} with
{code}
val vec2 = SparseVector.fromCoo(3, (1, 1.0))
{code}
should fix your problem.

The underlying problem is that the Scala compiler cannot cast a tuple of (Int, 
Int) to (Int, Double) even though Int values are a subset of Double. We could 
add methods which do this for us, though.

 Cannot create SparseVector with only one non-zero element.
 --

 Key: FLINK-1937
 URL: https://issues.apache.org/jira/browse/FLINK-1937
 Project: Flink
  Issue Type: Bug
  Components: Machine Learning Library
Reporter: Chiwan Park
Assignee: Till Rohrmann
  Labels: ML

 I tried creating SparseVector with only one non-zero element. But I couldn't 
 create it. Following code causes the problem.
 {code}
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 {code}
 I got a compile error following:
 {code:none}
 Error:(60, 29) overloaded method value fromCOO with alternatives:
   (size: Int,entries: Iterable[(Int, 
 Double)])org.apache.flink.ml.math.SparseVector and
   (size: Int,entries: (Int, Double)*)org.apache.flink.ml.math.SparseVector
  cannot be applied to (Int, (Int, Int))
 val vec2 = SparseVector.fromCOO(3, (1, 1))
 ^
 {code}



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