You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@systemml.apache.org by Deron Eriksson <de...@gmail.com> on 2016/06/29 20:23:29 UTC

print a value in a frame?

How do I print a value in a frame?

Suppose I have the following 2x2 csv file:
one,two
three,four

I read it in with:
M = read($Min, data_type='frame', format='csv');

(1)
If I try:
   print(M[1,1]);
I get:
   ERROR: null -- line 1, column 0 -- print statement can only print scalars

(2)
If I try:
   print(as.scalar(M[1,1]));
I get:
   ERROR: null -- line 2, column 7 -- Expecting matrix parameter for
function CAST_AS_SCALAR

(3)
If I try:
   print(as.scalar(as.matrix(M[1,1])));
I get:

 file:/.../src/test/scripts/org/apache/sysml/api/mlcontext/one-two-three-four.csv
not a SequenceFile

Thanks,
Deron

Re: print a value in a frame?

Posted by Matthias Boehm <mb...@us.ibm.com>.
that's a good point - there are still some classes of recompile
optimizations and rewrites that do not apply to frames yet. I'll look into
it.

Regards,
Matthias



From:	Deron Eriksson <de...@gmail.com>
To:	dev@systemml.incubator.apache.org
Date:	07/05/2016 04:14 PM
Subject:	Re: print a value in a frame?



Hi Matthias,

Perhaps I'm doing something wrong? If I try the following:

M = read($Min, data_type='frame', format='csv'); print(as.scalar(M[1,1]));

where the csv file is "one, two\nthree four", I am seeing:

Caused by: java.lang.ClassCastException:
org.apache.sysml.runtime.controlprogram.caching.FrameObject cannot be cast
to org.apache.sysml.runtime.controlprogram.caching.MatrixObject
at
org.apache.sysml.hops.recompile.LiteralReplacement.replaceLiteralValueTypeCastRightIndexing
(LiteralReplacement.java:306)


Deron



On Sun, Jul 3, 2016 at 1:11 PM, Matthias Boehm <mb...@us.ibm.com> wrote:

> quick correction: I meant to say, option 2 because you have a frame of
> strings (option 3 is only possible if you have numeric/boolean data).
Btw,
> it's fixed now - so please go ahead and give it a try. Thanks.
>
>
> Regards,
> Matthias
>
> [image: Inactive hide details for Deron Eriksson ---06/29/2016 01:40:01
> PM---Thanks for the quick reply. I'll use the toString() for no]Deron
> Eriksson ---06/29/2016 01:40:01 PM---Thanks for the quick reply. I'll use
> the toString() for now (for a unit test).
>
> From: Deron Eriksson <de...@gmail.com>
> To: dev@systemml.incubator.apache.org
> Date: 06/29/2016 01:40 PM
> Subject: Re: print a value in a frame?
> ------------------------------
>
>
>
> Thanks for the quick reply. I'll use the toString() for now (for a unit
> test).
>
> Deron
>
> On Wed, Jun 29, 2016 at 1:28 PM, Matthias Boehm <mb...@us.ibm.com>
wrote:
>
> > option 3 is possible but probably needs a fix. Alternatively, you can
use
> > print(toString(M)) which is implemented similar to the matrix toString
().
> >
> > Regards,
> > Matthias
> >
> > [image: Inactive hide details for Deron Eriksson ---06/29/2016 01:23:41
> > PM---How do I print a value in a frame? Suppose I have the foll]Deron
> > Eriksson ---06/29/2016 01:23:41 PM---How do I print a value in a frame?
> > Suppose I have the following 2x2 csv file:
> >
> > From: Deron Eriksson <de...@gmail.com>
> > To: dev@systemml.incubator.apache.org
> > Date: 06/29/2016 01:23 PM
> > Subject: print a value in a frame?
> > ------------------------------
>
> >
> >
> >
> > How do I print a value in a frame?
> >
> > Suppose I have the following 2x2 csv file:
> > one,two
> > three,four
> >
> > I read it in with:
> > M = read($Min, data_type='frame', format='csv');
> >
> > (1)
> > If I try:
> >   print(M[1,1]);
> > I get:
> >   ERROR: null -- line 1, column 0 -- print statement can only print
> scalars
> >
> > (2)
> > If I try:
> >   print(as.scalar(M[1,1]));
> > I get:
> >   ERROR: null -- line 2, column 7 -- Expecting matrix parameter for
> > function CAST_AS_SCALAR
> >
> > (3)
> > If I try:
> >   print(as.scalar(as.matrix(M[1,1])));
> > I get:
> >
> >
> >
>
file:/.../src/test/scripts/org/apache/sysml/api/mlcontext/one-two-three-four.csv

> > not a SequenceFile
> >
> > Thanks,
> > Deron
> >
> >
> >
>
>
>


Re: print a value in a frame?

Posted by Deron Eriksson <de...@gmail.com>.
Hi Matthias,

Perhaps I'm doing something wrong? If I try the following:

M = read($Min, data_type='frame', format='csv'); print(as.scalar(M[1,1]));

where the csv file is "one, two\nthree four", I am seeing:

Caused by: java.lang.ClassCastException:
org.apache.sysml.runtime.controlprogram.caching.FrameObject cannot be cast
to org.apache.sysml.runtime.controlprogram.caching.MatrixObject
at
org.apache.sysml.hops.recompile.LiteralReplacement.replaceLiteralValueTypeCastRightIndexing(LiteralReplacement.java:306)


Deron



On Sun, Jul 3, 2016 at 1:11 PM, Matthias Boehm <mb...@us.ibm.com> wrote:

> quick correction: I meant to say, option 2 because you have a frame of
> strings (option 3 is only possible if you have numeric/boolean data). Btw,
> it's fixed now - so please go ahead and give it a try. Thanks.
>
>
> Regards,
> Matthias
>
> [image: Inactive hide details for Deron Eriksson ---06/29/2016 01:40:01
> PM---Thanks for the quick reply. I'll use the toString() for no]Deron
> Eriksson ---06/29/2016 01:40:01 PM---Thanks for the quick reply. I'll use
> the toString() for now (for a unit test).
>
> From: Deron Eriksson <de...@gmail.com>
> To: dev@systemml.incubator.apache.org
> Date: 06/29/2016 01:40 PM
> Subject: Re: print a value in a frame?
> ------------------------------
>
>
>
> Thanks for the quick reply. I'll use the toString() for now (for a unit
> test).
>
> Deron
>
> On Wed, Jun 29, 2016 at 1:28 PM, Matthias Boehm <mb...@us.ibm.com> wrote:
>
> > option 3 is possible but probably needs a fix. Alternatively, you can use
> > print(toString(M)) which is implemented similar to the matrix toString().
> >
> > Regards,
> > Matthias
> >
> > [image: Inactive hide details for Deron Eriksson ---06/29/2016 01:23:41
> > PM---How do I print a value in a frame? Suppose I have the foll]Deron
> > Eriksson ---06/29/2016 01:23:41 PM---How do I print a value in a frame?
> > Suppose I have the following 2x2 csv file:
> >
> > From: Deron Eriksson <de...@gmail.com>
> > To: dev@systemml.incubator.apache.org
> > Date: 06/29/2016 01:23 PM
> > Subject: print a value in a frame?
> > ------------------------------
>
> >
> >
> >
> > How do I print a value in a frame?
> >
> > Suppose I have the following 2x2 csv file:
> > one,two
> > three,four
> >
> > I read it in with:
> > M = read($Min, data_type='frame', format='csv');
> >
> > (1)
> > If I try:
> >   print(M[1,1]);
> > I get:
> >   ERROR: null -- line 1, column 0 -- print statement can only print
> scalars
> >
> > (2)
> > If I try:
> >   print(as.scalar(M[1,1]));
> > I get:
> >   ERROR: null -- line 2, column 7 -- Expecting matrix parameter for
> > function CAST_AS_SCALAR
> >
> > (3)
> > If I try:
> >   print(as.scalar(as.matrix(M[1,1])));
> > I get:
> >
> >
> >
> file:/.../src/test/scripts/org/apache/sysml/api/mlcontext/one-two-three-four.csv
> > not a SequenceFile
> >
> > Thanks,
> > Deron
> >
> >
> >
>
>
>

Re: print a value in a frame?

Posted by Matthias Boehm <mb...@us.ibm.com>.
quick correction: I meant to say, option 2 because you have a frame of
strings (option 3 is only possible if you have numeric/boolean data). Btw,
it's fixed now - so please go ahead and give it a try. Thanks.


Regards,
Matthias



From:	Deron Eriksson <de...@gmail.com>
To:	dev@systemml.incubator.apache.org
Date:	06/29/2016 01:40 PM
Subject:	Re: print a value in a frame?



Thanks for the quick reply. I'll use the toString() for now (for a unit
test).

Deron

On Wed, Jun 29, 2016 at 1:28 PM, Matthias Boehm <mb...@us.ibm.com> wrote:

> option 3 is possible but probably needs a fix. Alternatively, you can use
> print(toString(M)) which is implemented similar to the matrix toString().
>
> Regards,
> Matthias
>
> [image: Inactive hide details for Deron Eriksson ---06/29/2016 01:23:41
> PM---How do I print a value in a frame? Suppose I have the foll]Deron
> Eriksson ---06/29/2016 01:23:41 PM---How do I print a value in a frame?
> Suppose I have the following 2x2 csv file:
>
> From: Deron Eriksson <de...@gmail.com>
> To: dev@systemml.incubator.apache.org
> Date: 06/29/2016 01:23 PM
> Subject: print a value in a frame?
> ------------------------------
>
>
>
> How do I print a value in a frame?
>
> Suppose I have the following 2x2 csv file:
> one,two
> three,four
>
> I read it in with:
> M = read($Min, data_type='frame', format='csv');
>
> (1)
> If I try:
>   print(M[1,1]);
> I get:
>   ERROR: null -- line 1, column 0 -- print statement can only print
scalars
>
> (2)
> If I try:
>   print(as.scalar(M[1,1]));
> I get:
>   ERROR: null -- line 2, column 7 -- Expecting matrix parameter for
> function CAST_AS_SCALAR
>
> (3)
> If I try:
>   print(as.scalar(as.matrix(M[1,1])));
> I get:
>
>
>
file:/.../src/test/scripts/org/apache/sysml/api/mlcontext/one-two-three-four.csv

> not a SequenceFile
>
> Thanks,
> Deron
>
>
>


Re: print a value in a frame?

Posted by Deron Eriksson <de...@gmail.com>.
Thanks for the quick reply. I'll use the toString() for now (for a unit
test).

Deron

On Wed, Jun 29, 2016 at 1:28 PM, Matthias Boehm <mb...@us.ibm.com> wrote:

> option 3 is possible but probably needs a fix. Alternatively, you can use
> print(toString(M)) which is implemented similar to the matrix toString().
>
> Regards,
> Matthias
>
> [image: Inactive hide details for Deron Eriksson ---06/29/2016 01:23:41
> PM---How do I print a value in a frame? Suppose I have the foll]Deron
> Eriksson ---06/29/2016 01:23:41 PM---How do I print a value in a frame?
> Suppose I have the following 2x2 csv file:
>
> From: Deron Eriksson <de...@gmail.com>
> To: dev@systemml.incubator.apache.org
> Date: 06/29/2016 01:23 PM
> Subject: print a value in a frame?
> ------------------------------
>
>
>
> How do I print a value in a frame?
>
> Suppose I have the following 2x2 csv file:
> one,two
> three,four
>
> I read it in with:
> M = read($Min, data_type='frame', format='csv');
>
> (1)
> If I try:
>   print(M[1,1]);
> I get:
>   ERROR: null -- line 1, column 0 -- print statement can only print scalars
>
> (2)
> If I try:
>   print(as.scalar(M[1,1]));
> I get:
>   ERROR: null -- line 2, column 7 -- Expecting matrix parameter for
> function CAST_AS_SCALAR
>
> (3)
> If I try:
>   print(as.scalar(as.matrix(M[1,1])));
> I get:
>
>
> file:/.../src/test/scripts/org/apache/sysml/api/mlcontext/one-two-three-four.csv
> not a SequenceFile
>
> Thanks,
> Deron
>
>
>

Re: print a value in a frame?

Posted by Matthias Boehm <mb...@us.ibm.com>.
option 3 is possible but probably needs a fix. Alternatively, you can use
print(toString(M)) which is implemented similar to the matrix toString().

Regards,
Matthias



From:	Deron Eriksson <de...@gmail.com>
To:	dev@systemml.incubator.apache.org
Date:	06/29/2016 01:23 PM
Subject:	print a value in a frame?



How do I print a value in a frame?

Suppose I have the following 2x2 csv file:
one,two
three,four

I read it in with:
M = read($Min, data_type='frame', format='csv');

(1)
If I try:
   print(M[1,1]);
I get:
   ERROR: null -- line 1, column 0 -- print statement can only print
scalars

(2)
If I try:
   print(as.scalar(M[1,1]));
I get:
   ERROR: null -- line 2, column 7 -- Expecting matrix parameter for
function CAST_AS_SCALAR

(3)
If I try:
   print(as.scalar(as.matrix(M[1,1])));
I get:


file:/.../src/test/scripts/org/apache/sysml/api/mlcontext/one-two-three-four.csv

not a SequenceFile

Thanks,
Deron