How does pairwise parameterization work in the unit test framework?

12 ビュー (過去 30 日間)
Brett Pantalone
Brett Pantalone 2019 年 8 月 3 日
回答済み: Alex Kashuba 2021 年 1 月 27 日
I have studied the example script in the documentation, but I can't see how the test parameters are being chosen in "pairwise" fashion. Why is the number of combinations 10 in this example? What is the algorithm to generate pairwise parameters?
  3 件のコメント
Greg
Greg 2020 年 4 月 28 日
8 months later and nothing on this? The documentation is extremely minimal on this, which is surprising and disappointing considering how thorough MATLAB documentation typically is. I would ask the additional question of what "pairwise" even means given the example has 3 input parameters - a group of 3 is not called a pair.

サインインしてコメントする。

採用された回答

Greg
Greg 2020 年 4 月 28 日
編集済み: Greg 2020 年 4 月 28 日
According to an answer on stack exchange, the minimum number of pairwise combinations is 9. The concept of pairwise combination takes any 2 parameters at a time, and doesn't care about the rest. The trivial solution to the example is:
  1. dim1.small x dim2.small x dim3.small
  2. dim1.small x dim2.medium x dim3.medium
  3. dim1.small x dim2.large x dim3.large
  4. dim1.medium x dim2.small x dim3.medium
  5. dim1.medium x dim2.medium x dim3.large
  6. dim1.medium x dim2.large x dim3.small
  7. dim1.large x dim2.small x dim3.large
  8. dim1.large x dim2.medium x dim3.small
  9. dim1.large x dim2.large x dim3.medium
We have every possible value pair you could draw from any pair of parameters, but we do not have every unique triplet (that would be the "exhaustive" approach, and result in 3x3x3 = 27 combinations).
I still have no idea where 10 comes from in the documentation example.

その他の回答 (1 件)

Alex Kashuba
Alex Kashuba 2021 年 1 月 27 日
I think the answer is following. Let say we have parameters
classdef PairwiseTest < matlab.unittest.TestCase
properties (TestParameter)
a = { '1', '2', '3', '4', '5'}
b = { '1', '2', '3', '4', '5'}
c = { '6', '7', '8'}
d = { '0', '9'}
end
methods(Test, ParameterCombination='pairwise')
function testPairwise(tc, a, b, c, d)
fprintf(['\n' a b c d ])
end
end
methods(Test, ParameterCombination='exhaustive')
function testPairAC(tc, a, c)
fprintf(['\n' a '_' c '_' ])
end
end
end
We get here for testPairwise
1160.
1279.
1380.
1469.
1560.
2170.
2260.
2369.
2480.
2579.
3189.
3260.
3379.
3470.
3589.
4160.
4289.
4370.
4479.
4580.
5160.
5279.
5389.
5460.
5579.
The run gives us such combinations that any pair of parameters (say a and c, but can be any other) are exhaustive i.e. all combitations of testPairAC are included:
1_6_.
1_7_.
1_8_.
2_6_.
2_7_.
2_8_.
3_6_.
3_7_.
3_8_.
4_6_.
4_7_.
4_8_.
5_6_.
5_7_.
5_8_.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by