Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
avocado
提交
20efad4b
A
avocado
项目概览
openeuler
/
avocado
通知
0
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
avocado
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
20efad4b
编写于
6月 18, 2019
作者:
C
Cleber Rosa
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'richtja/cit_bug'
Signed-off-by:
N
Cleber Rosa
<
crosa@redhat.com
>
上级
ad3425c2
da87e9dd
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
30 addition
and
13 deletion
+30
-13
optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py
optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py
+13
-6
optional_plugins/varianter_cit/tests/test_cit.py
optional_plugins/varianter_cit/tests/test_cit.py
+17
-7
未找到文件。
optional_plugins/varianter_cit/avocado_varianter_cit/Cit.py
浏览文件 @
20efad4b
...
@@ -101,6 +101,7 @@ class Cit:
...
@@ -101,6 +101,7 @@ class Cit:
while
self
.
combination_matrix
.
total_uncovered
!=
0
:
while
self
.
combination_matrix
.
total_uncovered
!=
0
:
LOG
.
debug
(
self
.
__throbber
.
render
(),
extra
=
{
"skip_newline"
:
True
})
LOG
.
debug
(
self
.
__throbber
.
render
(),
extra
=
{
"skip_newline"
:
True
})
solution
,
row_index
,
_
=
self
.
use_random_algorithm
(
matrix
)
solution
,
row_index
,
_
=
self
.
use_random_algorithm
(
matrix
)
if
len
(
solution
)
!=
0
:
self
.
combination_matrix
.
uncover_solution_row
(
matrix
[
row_index
])
self
.
combination_matrix
.
uncover_solution_row
(
matrix
[
row_index
])
self
.
combination_matrix
.
cover_solution_row
(
solution
)
self
.
combination_matrix
.
cover_solution_row
(
solution
)
matrix
[
row_index
]
=
solution
matrix
[
row_index
]
=
solution
...
@@ -197,8 +198,6 @@ class Cit:
...
@@ -197,8 +198,6 @@ class Cit:
self
.
combination_matrix
.
cover_combination
(
matrix
[
row_index
],
parameters
)
self
.
combination_matrix
.
cover_combination
(
matrix
[
row_index
],
parameters
)
if
best_uncover
==
0
:
if
best_uncover
==
0
:
break
break
if
len
(
best_solution
)
==
0
:
return
self
.
change_one_column
(
matrix
)
return
best_solution
,
best_row_index
,
parameters
return
best_solution
,
best_row_index
,
parameters
def
get_missing_combination_random
(
self
):
def
get_missing_combination_random
(
self
):
...
@@ -229,7 +228,10 @@ class Cit:
...
@@ -229,7 +228,10 @@ class Cit:
best_solution
=
[]
best_solution
=
[]
best_row_index
=
0
best_row_index
=
0
for
row_index
in
range
(
len
(
matrix
)):
for
row_index
in
range
(
len
(
matrix
)):
try
:
solution
,
row_index
,
parameters
=
self
.
change_one_value
(
matrix
,
row_index
,
column_index
)
solution
,
row_index
,
parameters
=
self
.
change_one_value
(
matrix
,
row_index
,
column_index
)
except
ValueError
:
continue
self
.
combination_matrix
.
uncover_combination
(
matrix
[
row_index
],
parameters
)
self
.
combination_matrix
.
uncover_combination
(
matrix
[
row_index
],
parameters
)
self
.
combination_matrix
.
cover_combination
(
solution
,
parameters
)
self
.
combination_matrix
.
cover_combination
(
solution
,
parameters
)
if
self
.
combination_matrix
.
total_uncovered
<
best_uncover
:
if
self
.
combination_matrix
.
total_uncovered
<
best_uncover
:
...
@@ -251,10 +253,13 @@ class Cit:
...
@@ -251,10 +253,13 @@ class Cit:
:param column_index: column inside matrix. If it's None it is chosen randomly
:param column_index: column inside matrix. If it's None it is chosen randomly
:return: solution, index of solution inside matrix and parameters which has been changed
:return: solution, index of solution inside matrix and parameters which has been changed
"""
"""
is_cell_chosen
=
True
if
row_index
is
None
:
if
row_index
is
None
:
is_cell_chosen
=
False
row_index
=
random
.
randint
(
0
,
len
(
matrix
)
-
1
)
row_index
=
random
.
randint
(
0
,
len
(
matrix
)
-
1
)
row
=
[
x
for
x
in
matrix
[
row_index
]]
row
=
[
x
for
x
in
matrix
[
row_index
]]
if
column_index
is
None
:
if
column_index
is
None
:
is_cell_chosen
=
False
column_index
=
random
.
randint
(
0
,
len
(
row
)
-
1
)
column_index
=
random
.
randint
(
0
,
len
(
row
)
-
1
)
possible_numbers
=
list
(
range
(
0
,
row
[
column_index
]))
+
list
(
possible_numbers
=
list
(
range
(
0
,
row
[
column_index
]))
+
list
(
range
(
row
[
column_index
]
+
1
,
self
.
data
[
column_index
]))
range
(
row
[
column_index
]
+
1
,
self
.
data
[
column_index
]))
...
@@ -262,6 +267,8 @@ class Cit:
...
@@ -262,6 +267,8 @@ class Cit:
while
not
self
.
combination_matrix
.
is_valid_combination
(
row
,
[
column_index
]):
while
not
self
.
combination_matrix
.
is_valid_combination
(
row
,
[
column_index
]):
possible_numbers
.
remove
(
row
[
column_index
])
possible_numbers
.
remove
(
row
[
column_index
])
if
len
(
possible_numbers
)
==
0
:
if
len
(
possible_numbers
)
==
0
:
if
is_cell_chosen
:
raise
ValueError
(
"Selected cell can't be changed"
)
column_index
=
random
.
randint
(
0
,
len
(
row
)
-
1
)
column_index
=
random
.
randint
(
0
,
len
(
row
)
-
1
)
row_index
=
random
.
randint
(
0
,
len
(
matrix
)
-
1
)
row_index
=
random
.
randint
(
0
,
len
(
matrix
)
-
1
)
row
=
[
x
for
x
in
matrix
[
row_index
]]
row
=
[
x
for
x
in
matrix
[
row_index
]]
...
...
optional_plugins/varianter_cit/tests/test_cit.py
浏览文件 @
20efad4b
...
@@ -71,13 +71,23 @@ class CitTests(unittest.TestCase):
...
@@ -71,13 +71,23 @@ class CitTests(unittest.TestCase):
final_matrix
=
self
.
cit
.
final_matrix_init
()
final_matrix
=
self
.
cit
.
final_matrix_init
()
expected_row_index
=
2
expected_row_index
=
2
expected_column_index
=
0
expected_column_index
=
0
function_state
=
True
row
,
row_index
,
column_index
=
(
None
,
None
,
None
)
try
:
row
,
row_index
,
column_index
=
self
.
cit
.
change_one_value
(
final_matrix
,
row_index
=
expected_row_index
,
row
,
row_index
,
column_index
=
self
.
cit
.
change_one_value
(
final_matrix
,
row_index
=
expected_row_index
,
column_index
=
expected_column_index
)
column_index
=
expected_column_index
)
except
ValueError
:
function_state
=
False
if
function_state
:
self
.
assertEqual
(
expected_column_index
,
column_index
[
0
],
"Column index is wrong"
)
self
.
assertEqual
(
expected_column_index
,
column_index
[
0
],
"Column index is wrong"
)
self
.
assertEqual
(
expected_row_index
,
row_index
,
"Row index is wrong"
)
self
.
assertEqual
(
expected_row_index
,
row_index
,
"Row index is wrong"
)
self
.
assertNotEqual
(
final_matrix
[
row_index
][
column_index
[
0
]],
row
[
column_index
[
0
]],
"Value did not change"
)
self
.
assertNotEqual
(
final_matrix
[
row_index
][
column_index
[
0
]],
row
[
column_index
[
0
]],
"Value did not change"
)
row
[
column_index
[
0
]]
=
final_matrix
[
row_index
][
column_index
[
0
]]
row
[
column_index
[
0
]]
=
final_matrix
[
row_index
][
column_index
[
0
]]
self
.
assertEqual
(
final_matrix
[
row_index
],
row
,
"Different value was changed"
)
self
.
assertEqual
(
final_matrix
[
row_index
],
row
,
"Different value was changed"
)
else
:
self
.
assertIsNone
(
row
)
self
.
assertIsNone
(
row_index
)
self
.
assertIsNone
(
column_index
)
def
test_change_one_column
(
self
):
def
test_change_one_column
(
self
):
final_matrix
=
self
.
cit
.
final_matrix_init
()
final_matrix
=
self
.
cit
.
final_matrix_init
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录