Macro values not VALIDATED correctly

Unknown
edited November 5 in Community Q&A
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
Tagged:

Answers

  • MariusHelf
    MariusHelf New Altair Community Member
    As always, you are right :) 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
  • Hi Marius
    yeah mama and me are always right  ;D


    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.
  • MariusHelf
    MariusHelf New Altair Community Member
    Which operator are you exactly referring to?
  • Marius wrote:

    Which operator are you exactly referring to?
    Discretize by user specification
  • MariusHelf
    MariusHelf New Altair Community Member
    Can you please provide an example process? For me, the following process works like a charm:
    <?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>
  • 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?

    Marius wrote:

    Can you please provide an example process? For me, the following process works like a charm:
    <?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>
  • 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.
  • MariusHelf
    MariusHelf New Altair Community Member
    Ok, I can reproduce that.
    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.
    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 :)

    Best, Marius
  • Marius wrote:

    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

    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 :)

    Best, Marius
    ;D

    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.
  • MariusHelf
    MariusHelf New Altair Community Member
    fritmore wrote:
    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.