"Generate attribute if clause"

MuehliMan
MuehliMan New Altair Community Member
edited November 5 in Community Q&A
Hello again,

I have troubles getting an operator to work:
<operator activated="true" class="generate_attributes" compatibility="5.0.0" expanded="true" height="76" name="Generate Attributes (27)" width="90" x="179" y="435">
            <list key="function_descriptions">
              <parameter key="PT" value="if( PT_old=NaN , PT_add , PT_old )"/>
            </list>
            <parameter key="keep_all" value="true"/>
          </operator>
I want to add the values from the attributes "PT_old" and "PT_add" to the new column PT.

Thanks in advance,
Markus



Answers

  • haddock
    haddock New Altair Community Member
    Hi there,

    Unfortunately the formula parser does not recognise NaN, so you have to fool it if you can! With numbers this seems to work..
    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.0">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" expanded="true" name="Process">
       <process expanded="true" height="161" width="681">
         <operator activated="true" class="retrieve" expanded="true" height="60" name="Retrieve" width="90" x="113" y="63">
           <parameter key="repository_entry" value="//Samples/data/Labor-Negotiations"/>
         </operator>
         <operator activated="true" class="generate_attributes" expanded="true" height="76" name="Generate Attributes" width="90" x="313" y="75">
           <list key="function_descriptions">
             <parameter key="Numbers" value="if(duration*duration&gt;-1,5,8)"/>
           </list>
         </operator>
         <connect from_op="Retrieve" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
         <connect from_op="Generate Attributes" 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>
    Not quite sure what you'd do for nominals, but you get the idea..

  • cherokee
    cherokee New Altair Community Member
    Hi!

    Just a small remark! Even in Java NaN==NaN is allways false.

    It's feature not a bug!  ;)

    Best regards,
    chero