Opened 12 years ago

Closed 9 years ago

#372 closed defect (duplicate)

WCPS1.5_Returns Boolean, Binary scalar expressions without encoding

Reported by: Piero Campalani Owned by: Alex Dumitru
Priority: major Milestone: 10.0
Component: petascope Version: development
Keywords: boolean scalar expression Cc: Vlad Merticariu, Dimitar Misev
Complexity: Medium

Description

Apparently, boolean scalar expressions are not always recognized:

# OK
for a in (mean_summer_airtemp)
   return TRUE
# ERROR 
for a in (mean_summer_airtemp)
   return (a[x:"CRS:1"(100),y:"CRS:1"(300)] = 0)

Related Petascope WCPS grammar (petascope.wcps.grammar.wcps.g):

booleanScalarExpr returns[BooleanScalarExpr value]
    : e1=booleanScalarTerm { $value = $e1.value; }
      (op=(OR|XOR) e2=booleanScalarTerm { $value = new BooleanScalarExpr($op.text, $value, $e2.value);})*
    ;   
booleanScalarTerm returns[BooleanScalarExpr value]
        : e1=booleanScalarNegation { $value = $e1.value; }
          (op=AND e2=booleanScalarNegation { $value = new BooleanScalarExpr($op.text, $value, $e2.value); } )*
        ;   
booleanScalarNegation  returns[BooleanScalarExpr value]
        :       e1=booleanScalarAtom { $value = $e1.value; }
        |       op=NOT e1=booleanScalarAtom { $value = new BooleanScalarExpr($op.text, $e1.value); }
        ;   
booleanScalarAtom returns[BooleanScalarExpr value]
        : LPAREN e1=booleanScalarExpr RPAREN { $value = $e1.value; }
        | s1=stringScalarExpr cop=compOp s2=stringScalarExpr { $value = new BooleanScalarExpr($cop.value, $s1.value, $s2.value); } 
        | n1=numericScalarExpr cop=compOp n2=numericScalarExpr { $value = new BooleanScalarExpr($cop.value, $n1.value, $n2.value); } 
        | e=BOOLEANCONSTANT { $value = new BooleanScalarExpr($e.text); }
        ;   

WCPS standard:

booleanScalarExpr:
  | booleanScalarExpr and booleanScalarTerm
  | booleanScalarExpr or booleanScalarTerm
  | booleanScalarExpr xor booleanScalarTerm
  | booleanScalarTerm

booleanScalarTerm:
  | booleanScalarTerm and booleanScalarFactor
  | booleanScalarTerm or booleanScalarFactor
  | booleanScalarTerm xor booleanScalarFactor
  | booleanScalarFactor

booleanScalarFactor:
  | numericScalarExpr compOp numericScalarExpr
  | stringScalarExpr compOp stringScalarExpr
  | not booleanScalarExpr
  | booleanConstant

Change History (8)

comment:1 by Dimitar Misev, 12 years ago

Piero, please use the test coverages (rgb, mr, eobstest), or add the mean_summer_airtemp to the systemtest, so that everyone can easily run examples.

comment:2 by Dimitar Misev, 12 years ago

Milestone: 8.5Future
Priority: majorminor

I think the issue is that the grammar can't figure out that

a[x:"CRS:1"(100),y:"CRS:1"(300)]

is a scalar, i.e. it's considered a coverage, and equality of coverage and a scalar doesn't make sense.

This works for example, reducing explicitly the coverage to a scalar:

for c in (mr)
   return (max(c[x(100:100),y(100:100)]) = 1)

So there's a workaround. I'll put this on low priority, we could try to fix it at some point.

comment:3 by Dimitar Misev, 10 years ago

Owner: changed from abeccati to uadhikari
Status: newassigned

Reassigning to Utkrist, he's worked recently on the WCPS grammar.

comment:4 by Dimitar Misev, 10 years ago

Remove the ':"CRS:1"' from the queries, and change axis names to i/j from x/y.

Last edited 10 years ago by Dimitar Misev (previous) (diff)

comment:5 by Dimitar Misev, 9 years ago

Owner: changed from uadhikari to Alex Dumitru

comment:6 by Bang Pham Huu, 9 years ago

Cc: Vlad Merticariu Dimitar Misev added; Dirk Daems removed
Milestone: Future10.0
Priority: minormajor
Summary: Boolean scalar expressionsWCPS1.5_Returns Boolean, Binary scalar expressions without encoding
Version: 8.4development

I will regard to WCPS1.5, now, it does not support to returns a Boolean / Binary Operator of Scalar Expression without encoding, i.e:

 for c in (mr) return c[i(0), j(0)] + 5 

or

 for c in (mr) return c[i(0), j(0)] = 0 

An workaround is using "encode" and it will work in both cases

for c in (mr) return encode(c[i(0), j(0)] + 5, "csv")

So, I will leave for discussion, should every WCPS query without "encoding" will implicitly encode the result into "csv".

i.e: WCPS query:

for c in (mr) return c[i(0), j(0)] = 0 is equivalent to
for c in (mr) return encode(c[i(0), j(0)] = 0).

Then this ticket can be solved quickly.

comment:7 by Dimitar Misev, 9 years ago

It shouldn't return csv if there is no encode, but simply the single scalar value.

I guess if it makes your life easier you could internally encode to csv and then before returning to the user remove the '{' and '}' from the result. But that doesn't sound very elegant.

comment:8 by Bang Pham Huu, 9 years ago

Resolution: duplicate
Status: assignedclosed

I will close this ticket and merge it with http://rasdaman.org/ticket/1270 as it has the same problem and will be fixed in WCPS 1.5.

Note: See TracTickets for help on using tickets.