You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ENH: Support (expr)[T, C] sub-expression tuple+component extraction
Adds TupleComponentExtract as a new RPN item type that extracts a single
scalar value from a computed sub-expression result at a specific tuple
and component index. Produces a Number that broadcasts like a literal.
Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
// Case B: )[C] -- component extraction on sub-expression result
711
-
if(bracketNumbers.size() != 1)
712
+
// Case B: )[C] or )[T, C] -- extraction on sub-expression result
713
+
if(bracketNumbers.size() == 1)
712
714
{
713
-
returnMakeErrorResult(static_cast<int>(CalculatorErrorCode::InvalidComponent), "Component extraction on sub-expression must have exactly one index: [C].");
returnMakeErrorResult(static_cast<int>(CalculatorErrorCode::InvalidComponent), fmt::format("Invalid tuple/component index in '[{}, {}]'.", bracketNumbers[0], bracketNumbers[1]));
returnMakeErrorResult(static_cast<int>(CalculatorErrorCode::NoNumericArguments), "The expression does not have any arguments that simplify down to a number.");
1335
1361
}
1336
1362
1337
-
// Check if there is a ComponentExtract item in the parsed list.
1338
-
//If so, the final output will be single-component regardless of the
1339
-
//input array's component shape.
1363
+
// Check if there is a ComponentExtract or TupleComponentExtract item in the parsed list.
1364
+
//ComponentExtract produces a single-component array.
1365
+
//TupleComponentExtract produces a scalar (single tuple, single component).
returnMakeErrorResult(static_cast<int>(CalculatorErrorCode::InvalidEquation), "Internal error: could not find operand array for tuple+component extraction.");
returnMakeErrorResult(static_cast<int>(CalculatorErrorCode::TupleOutOfRange), fmt::format("Tuple index {} is out of range for array with {} tuples.", tupleIdx, numTuples));
1718
+
}
1719
+
if(compIdx >= numComps)
1720
+
{
1721
+
returnMakeErrorResult(static_cast<int>(CalculatorErrorCode::ComponentOutOfRange), fmt::format("Component index {} is out of range for array with {} components.", compIdx, numComps));
1722
+
}
1723
+
1724
+
double value = operandArr->at(tupleIdx * numComps + compIdx);
0 commit comments