You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@spark.apache.org by Manoj Kumar <ma...@gmail.com> on 2015/02/03 13:17:22 UTC

Accessing indices and values in SparseVector

Hello,

This is related to one of the issues that I'm working on. I am not sure if
this is expected behavior or not.

This works fine.
val sv2 = new SparseVector(3, Array(0, 2), Array(1.1, 3.0))
sv2.indices

But when I do this
val sv2: Vector = Vectors.sparse(3, Array(0, 2), Array(1.1, 3.0))
sv2.indices

It raises an error.

If agreed that this is not expected, I can send a Pull Request.
Thanks.



-- 
Godspeed,
Manoj Kumar,
http://manojbits.wordpress.com
<http://goog_1017110195>
http://github.com/MechCoder

Re: Accessing indices and values in SparseVector

Posted by Manoj Kumar <ma...@gmail.com>.
Alright, thanks for the quick clarification.

Re: Accessing indices and values in SparseVector

Posted by Sean Owen <so...@cloudera.com>.
When you are describing an error, you should say what the error is.
Here I'm pretty sure it says there is no such member of Vector, right?
You explicitly made the type of sv2 Vector and not SparseVector, and
the trait does not have any indices member. No it's not a problem, and
I think the compiler tells you what's happening in this case.

On Tue, Feb 3, 2015 at 6:17 AM, Manoj Kumar
<ma...@gmail.com> wrote:
> Hello,
>
> This is related to one of the issues that I'm working on. I am not sure if
> this is expected behavior or not.
>
> This works fine.
> val sv2 = new SparseVector(3, Array(0, 2), Array(1.1, 3.0))
> sv2.indices
>
> But when I do this
> val sv2: Vector = Vectors.sparse(3, Array(0, 2), Array(1.1, 3.0))
> sv2.indices
>
> It raises an error.
>
> If agreed that this is not expected, I can send a Pull Request.
> Thanks.
>
>
>
> --
> Godspeed,
> Manoj Kumar,
> http://manojbits.wordpress.com
> <http://goog_1017110195>
> http://github.com/MechCoder

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@spark.apache.org
For additional commands, e-mail: dev-help@spark.apache.org