cartprod¶
Parameters¶
Parameter label |
I/O type |
Data type |
Mandatory parameter? |
Default value |
---|---|---|---|---|
|
input |
vector / scalar |
yes |
|
|
input |
vector / scalar |
yes |
|
|
input |
vector / scalar |
no |
N/A |
|
input |
vector / scalar |
no |
N/A |
|
input |
vector / scalar |
no |
N/A |
|
input |
string ( |
no |
“front” |
|
input |
scalar |
no |
0 |
|
output |
vector / scalar |
N/A |
N/A |
Functionality¶
Module creates the Cartesian product of 2 up to 5 input vectors. Here’s a simple example:
inputVec1 = [0,1,2,3]
inputVec2 = [2,2,4,4]
...
outputVec = ([0,2],[1,2],[2,4],[3,4])
If the input vectors have different lengths, the shorter vectors are filled up with paddingValue
in the front,
if paddingMode="front"
or in the back, if paddingMode="back"
before the Cartesian product is generated.
Here’s an example for the padding (taken from the module’s unit test):
m = MelopyFeatureModuleCartProd()
m.setParameterValue("inputVec1", np.array([1,2,3,4,5,6]))
m.setParameterValue("inputVec2", np.array([11,22,33,44,55]))
m.setParameterValue("inputVec3", np.array([111,222,333,444]))
# front padding
m.setParameterValue("paddingMode", "front")
m.process()
self.assertEqual(m.getParameterValue("outputVec"), \
([1, 0, 0], [2, 11, 0], [3, 22, 111], [4, 33, 222], [5, 44, 333], [6, 55, 444]))
# back padding
m.setParameterValue("paddingMode", "back")
m.process()
self.assertEqual(m.getParameterValue("outputVec"), \
([1, 11, 111], [2, 22, 222], [3, 33, 333], [4, 44, 444], [5, 55, 0], [6, 0, 0]))