Pages: [1]
  Print  
Author Topic: Macro values not VALIDATED correctly  (Read 1843 times)
fritmore
Jr. Member
**
Posts: 93


« on: August 29, 2012, 03:00:53 AM »

Hi

currently macro values are not always recognized as its proper "compiled" type and tons of error messages are thrown.
These bogus errors just obscure possible real errors(and it just looks plain bad -_-).

For example when I use a macro for substituting  Label attribute name, the validation wont recognize the %{LabelAttName} as a proper correct Label type.


thx
Logged
Marius
Administrator
Hero Member
*****
Posts: 1792



WWW
« Reply #1 on: August 29, 2012, 10:43:09 AM »

As always, you are right Smiley However, macro evaluation prior to running the process is not trivial - often macro values are changed during execution, so you never know what will be the final value when the operator is finally executed. We already have a bug report for this: http://bugs.rapid-i.com/show_bug.cgi?id=448

Best, Marius
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
fritmore
Jr. Member
**
Posts: 93


« Reply #2 on: August 29, 2012, 05:10:55 PM »

Hi Marius
yeah mama and me are always right  Grin


Yes the bug is talking about exactly the same thing but using nicer wording than me -_^.


ANOTHER thing though:
Macro CANNOT be used to Substitute a numerical value in e.g.  Discretize operator(discretization threashold)).

It would be nice to be able to substitute ANY value in any operator.
Logged
Marius
Administrator
Hero Member
*****
Posts: 1792



WWW
« Reply #3 on: August 29, 2012, 05:15:06 PM »

Which operator are you exactly referring to?
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
fritmore
Jr. Member
**
Posts: 93


« Reply #4 on: August 29, 2012, 05:37:11 PM »

Which operator are you exactly referring to?
Discretize by user specification
Logged
Marius
Administrator
Hero Member
*****
Posts: 1792



WWW
« Reply #5 on: August 29, 2012, 05:54:48 PM »

Can you please provide an example process? For me, the following process works like a charm:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.009">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.2.009" expanded="true" name="Process">
    <process expanded="true" height="389" width="727">
      <operator activated="true" class="generate_data" compatibility="5.2.009" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30"/>
      <operator activated="true" class="set_macro" compatibility="5.2.009" expanded="true" height="76" name="Set Macro" width="90" x="179" y="30">
        <parameter key="macro" value="value"/>
        <parameter key="value" value="3"/>
      </operator>
      <operator activated="true" class="generate_attributes" compatibility="5.2.009" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="30">
        <list key="function_descriptions">
          <parameter key="att1_clone" value="att1"/>
        </list>
      </operator>
      <operator activated="true" class="discretize_by_user_specification" compatibility="5.2.009" expanded="true" height="94" name="Discretize" width="90" x="447" y="30">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="att1"/>
        <list key="classes">
          <parameter key="first" value="%{value}"/>
          <parameter key="last" value="Infinity"/>
        </list>
      </operator>
      <connect from_op="Generate Data" from_port="output" to_op="Set Macro" to_port="through 1"/>
      <connect from_op="Set Macro" from_port="through 1" to_op="Generate Attributes" to_port="example set input"/>
      <connect from_op="Generate Attributes" from_port="example set output" to_op="Discretize" to_port="example set input"/>
      <connect from_op="Discretize" from_port="example set output" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
fritmore
Jr. Member
**
Posts: 93


« Reply #6 on: August 29, 2012, 07:10:58 PM »

try negative value like this  -%{value} instead, this will not work.

ok why not make the value already a negative number.... I say: why would I?



Can you please provide an example process? For me, the following process works like a charm:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="5.2.009">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="5.2.009" expanded="true" name="Process">
    <process expanded="true" height="389" width="727">
      <operator activated="true" class="generate_data" compatibility="5.2.009" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30"/>
      <operator activated="true" class="set_macro" compatibility="5.2.009" expanded="true" height="76" name="Set Macro" width="90" x="179" y="30">
        <parameter key="macro" value="value"/>
        <parameter key="value" value="3"/>
      </operator>
      <operator activated="true" class="generate_attributes" compatibility="5.2.009" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="30">
        <list key="function_descriptions">
          <parameter key="att1_clone" value="att1"/>
        </list>
      </operator>
      <operator activated="true" class="discretize_by_user_specification" compatibility="5.2.009" expanded="true" height="94" name="Discretize" width="90" x="447" y="30">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="att1"/>
        <list key="classes">
          <parameter key="first" value="%{value}"/>
          <parameter key="last" value="Infinity"/>
        </list>
      </operator>
      <connect from_op="Generate Data" from_port="output" to_op="Set Macro" to_port="through 1"/>
      <connect from_op="Set Macro" from_port="through 1" to_op="Generate Attributes" to_port="example set input"/>
      <connect from_op="Generate Attributes" from_port="example set output" to_op="Discretize" to_port="example set input"/>
      <connect from_op="Discretize" from_port="example set output" to_port="result 1"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
    </process>
  </operator>
</process>
« Last Edit: August 29, 2012, 07:45:36 PM by fritmore » Logged
fritmore
Jr. Member
**
Posts: 93


« Reply #7 on: August 29, 2012, 09:23:51 PM »

After confirming this kind of value  -%{val2} it will simply disappear.

When a simple expression is used as a parameter %{val1}-%{val2} ....  it is parsed and substituted (e.g. as 3-1) but not executed.
Logged
Marius
Administrator
Hero Member
*****
Posts: 1792



WWW
« Reply #8 on: August 30, 2012, 09:28:34 AM »

Ok, I can reproduce that.

Quote
When a simple expression is used as a parameter %{val1}-%{val2} ....  it is parsed and substituted (e.g. as 3-1) but not executed.
Operator fields are dumb - they never parse expressions, but expect ready made values, i.e. numbers in this case. You have to use Generate Macro to calculate new macro values from existing ones.

Quote
After confirming this kind of value  -%{val2} it will simply disappear.
Here we made our lives easy: in this field you are only allowed to enter numbers. So we are checking if you either entered a number, or if you entered a macro (more precise: if the expression starts with "%{"). I admit that this is improvable, but until now it is sufficient in 99% of all cases Smiley

Best, Marius
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
fritmore
Jr. Member
**
Posts: 93


« Reply #9 on: August 30, 2012, 06:28:37 PM »

Ok, I can reproduce that.
Operator fields are dumb - they never parse expressions, but expect ready made values, i.e. numbers in this case. You have to use Generate Macro to calculate new macro values from existing ones.

ok

Quote
Here we made our lives easy: in this field you are only allowed to enter numbers. So we are checking if you either entered a number, or if you entered a macro (more precise: if the expression starts with "%{"). I admit that this is improvable, but until now it is sufficient in 99% of all cases Smiley

Best, Marius
Grin

thx , M.
f

p.s.: I think I am not the only one who does not utilize the macros to their fullest, maybe you should dedicated some space to it in the upcoming Operator manual.
p.p.s.:It turned out to be more of a problem solving than a feature request.
« Last Edit: August 30, 2012, 06:34:37 PM by fritmore » Logged
Marius
Administrator
Hero Member
*****
Posts: 1792



WWW
« Reply #10 on: August 31, 2012, 08:42:15 AM »

p.s.: I think I am not the only one who does not utilize the macros to their fullest, maybe you should dedicated some space to it in the upcoming Operator manual.
Probably not in the operator reference, since macros are a concept which can't be easily explained in a operator-wise reference. But we'll probably write some more extensive documentation on a lot of topics, also the macros.
Logged

Please add [SOLVED] to the topic title when your problem has been solved! (do so by editing the first post in the thread and modifying the title)
Please click here before posting.
Pages: [1]
  Print  
 
Jump to: