Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Merge requests
!78
Resolve
L2SS-247
"2021 07 06 branched from master attribute testing"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve
L2SS-247
"2021 07 06 branched from master attribute testing"
L2SS-247_2021-07-06-Branched_from_master-attribute_testing
into
master
Overview
22
Commits
29
Pipelines
0
Changes
11
All threads resolved!
Hide all comments
Merged
Corné Lukken
requested to merge
L2SS-247_2021-07-06-Branched_from_master-attribute_testing
into
master
3 years ago
Overview
22
Commits
29
Pipelines
0
Changes
1
All threads resolved!
Hide all comments
Expand
Closes
L2SS-247
Edited
3 years ago
by
Taya Snijder
0
0
Merge request reports
Compare
version 4
version 14
f5cac74b
3 years ago
version 13
2eecc182
3 years ago
version 12
c2dd875c
3 years ago
version 11
3b2f8976
3 years ago
version 10
de58c195
3 years ago
version 9
4de0968b
3 years ago
version 8
78befe64
3 years ago
version 7
999ec5b5
3 years ago
version 6
4662191a
3 years ago
version 5
e41b96b2
3 years ago
version 4
658e6e66
3 years ago
version 3
a22b2521
3 years ago
version 2
2ece1d48
3 years ago
version 1
7a2226a0
3 years ago
master (base)
and
version 5
latest version
784891c7
29 commits,
3 years ago
version 14
f5cac74b
28 commits,
3 years ago
version 13
2eecc182
27 commits,
3 years ago
version 12
c2dd875c
26 commits,
3 years ago
version 11
3b2f8976
25 commits,
3 years ago
version 10
de58c195
24 commits,
3 years ago
version 9
4de0968b
23 commits,
3 years ago
version 8
78befe64
21 commits,
3 years ago
version 7
999ec5b5
20 commits,
3 years ago
version 6
4662191a
19 commits,
3 years ago
version 5
e41b96b2
18 commits,
3 years ago
version 4
658e6e66
17 commits,
3 years ago
version 3
a22b2521
16 commits,
3 years ago
version 2
2ece1d48
15 commits,
3 years ago
version 1
7a2226a0
14 commits,
3 years ago
Show latest version
1 file
+
93
−
54
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
devices/test/clients/test_attr_wrapper.py
+
93
−
54
Options
@@ -535,62 +535,101 @@ class TestAttributeTypes(base.TestCase):
def
readback_test
(
self
,
dev
,
dtype
,
test_type
):
'''
Test device
'''
with
DeviceTestContext
(
dev
,
process
=
True
)
as
proxy
:
#initialise
proxy
.
initialise
()
proxy
.
on
()
try
:
with
DeviceTestContext
(
dev
,
process
=
True
)
as
proxy
:
#initialise
proxy
.
initialise
()
proxy
.
on
()
if
test_type
==
"
scalar
"
:
if
dtype
is
str
or
dtype
is
numpy
.
str_
:
val
=
'
1
'
else
:
val
=
dtype
(
1
)
proxy
.
scalar_RW
=
val
result_R
=
proxy
.
scalar_R
result_RW
=
proxy
.
scalar_RW
elif
test_type
==
"
spectrum
"
:
if
dtype
is
str
or
dtype
is
numpy
.
str_
:
val
=
[
'
1
'
,
'
1
'
,
'
1
'
,
'
1
'
]
else
:
val
=
numpy
.
full
((
4
,),
dtype
=
dtype
,
fill_value
=
1
)
proxy
.
spectrum_RW
=
val
result_R
=
proxy
.
spectrum_R
result_RW
=
proxy
.
spectrum_RW
elif
test_type
==
"
image
"
:
if
dtype
is
str
or
dtype
is
numpy
.
str_
:
val
=
[[
'
1
'
,
'
1
'
],[
'
1
'
,
'
1
'
],[
'
1
'
,
'
1
'
]]
else
:
val
=
numpy
.
full
((
3
,
2
),
dtype
=
dtype
,
fill_value
=
1
)
# info += " write value: {}".format(val)
proxy
.
image_RW
=
val
result_R
=
proxy
.
image_R
result_RW
=
proxy
.
image_RW
# info += " value stored in RW: {} value read back in R {}".format(result_RW, result_R)
if
test_type
==
"
scalar
"
:
if
dtype
is
str
or
dtype
is
numpy
.
str_
:
val
=
'
1
'
else
:
val
=
dtype
(
1
)
proxy
.
scalar_RW
=
val
result_R
=
proxy
.
scalar_R
result_RW
=
proxy
.
scalar_RW
elif
test_type
==
"
spectrum
"
:
if
dtype
is
str
or
dtype
is
numpy
.
str_
:
val
=
[
'
1
'
,
'
1
'
,
'
1
'
,
'
1
'
]
else
:
val
=
numpy
.
full
((
4
,),
dtype
=
dtype
,
fill_value
=
1
)
proxy
.
spectrum_RW
=
val
result_R
=
proxy
.
spectrum_R
result_RW
=
proxy
.
spectrum_RW
elif
test_type
==
"
image
"
:
if
dtype
is
str
or
dtype
is
numpy
.
str_
:
val
=
[[
'
1
'
,
'
1
'
],[
'
1
'
,
'
1
'
],[
'
1
'
,
'
1
'
]]
else
:
val
=
numpy
.
full
((
3
,
2
),
dtype
=
dtype
,
fill_value
=
1
)
proxy
.
image_RW
=
val
result_R
=
proxy
.
image_R
result_RW
=
proxy
.
image_RW
# cant use all() for 2d arrays so instead compare the dimensions and then flatten to 2d
try
:
self
.
assertEqual
(
result_R
.
shape
,
(
3
,
2
),
"
image R array dimensions got mangled. Expected (2,3), got {}
"
.
format
(
result_R
.
shape
))
self
.
assertEqual
(
result_RW
.
shape
,
(
3
,
2
),
"
image RW array dimensions got mangled. Expected (2,3), got {}
"
.
format
(
result_RW
.
shape
))
except
:
pass
else
:
self
.
assertEqual
(
1
,
2
,
"
{} is not a valid test_type. please use either scalar, spectrum or image
"
.
format
(
test_type
))
try
:
comparison
=
result_RW
==
val
equal_arrays
=
comparison
.
all
()
self
.
assertTrue
(
equal_arrays
,
"
Value could not be handled by the atrribute_wrappers internal RW storer
"
)
except
:
pass
try
:
comparison
=
result_R
==
result_RW
equal_arrays
=
comparison
.
all
()
self
.
assertTrue
(
equal_arrays
,
"
written value not present in clients R attribute
"
)
except
:
pass
print
(
"
✅ Test passed! Managed write and read back a value: {}
"
.
format
(
val
))
# if the test isn't scalar/spectrum or image its wrong
self
.
assertEqual
(
1
,
2
,
"
{} is not a valid test_type. please use either scalar, spectrum or image
"
.
format
(
test_type
))
if
test_type
==
"
spectrum
"
:
if
dtype
==
str
:
self
.
assertEqual
(
len
(
result_RW
),
4
,
"
image RW str image dimensions got mangled. Expected 4, got {}
"
.
format
(
len
(
result_RW
)))
self
.
assertEqual
(
len
(
result_R
),
4
,
"
image RW str image dimensions got mangled. Expected 4, got {}
"
.
format
(
len
(
result_R
)))
else
:
comparison
=
result_RW
==
val
equal_arrays
=
comparison
.
all
()
self
.
assertTrue
(
equal_arrays
,
"
Value could not be handled by the atrribute_wrappers internal RW storer
"
)
comparison
=
result_R
==
result_RW
equal_arrays
=
comparison
.
all
()
self
.
assertTrue
(
equal_arrays
,
"
written value not present in clients R attribute
"
)
elif
test_type
==
"
scalar
"
:
comparison
=
result_RW
==
val
self
.
assertTrue
(
comparison
,
"
Value could not be handled by the atrribute_wrappers internal RW storer
"
)
comparison
=
result_R
==
result_RW
self
.
assertTrue
(
comparison
,
"
written value not present in clients R attribute
"
)
elif
test_type
==
"
image
"
:
if
dtype
!=
str
:
# images cant bee compared. instead just do the shape
self
.
assertEqual
(
result_R
.
shape
,
(
3
,
2
),
"
image R array dimensions got mangled. Expected (2,3), got {}
"
.
format
(
result_R
.
shape
))
self
.
assertEqual
(
result_RW
.
shape
,
(
3
,
2
),
"
image RW array dimensions got mangled. Expected (2,3), got {}
"
.
format
(
result_RW
.
shape
))
else
:
# str doesnt have shape, jsut comapre the lenghts
self
.
assertEqual
(
len
(
result_RW
),
3
,
"
image RW str image dimensions got mangled. Expected 3, got {}
"
.
format
(
len
(
result_RW
)))
self
.
assertEqual
(
len
(
result_RW
[
0
]),
2
,
"
image RW str image dimensions got mangled. Expected 2, got {}
"
.
format
(
len
(
result_RW
)))
self
.
assertEqual
(
len
(
result_R
),
3
,
"
image RW str image dimensions got mangled. Expected 3, got {}
"
.
format
(
len
(
result_R
)))
self
.
assertEqual
(
len
(
result_R
[
0
]),
2
,
"
image RW str image dimensions got mangled. Expected 2, got {}
"
.
format
(
len
(
result_R
)))
print
(
"
✅ Test passed! Managed write and read back a value: {}
"
.
format
(
val
))
except
Exception
as
e
:
info
=
"
Test failure in {} {} readback test
\n\t
W: {}
\n\t
RW: {}
\n\t
R: {}
"
.
format
(
test_type
,
dtype
,
val
,
result_RW
,
result_R
)
raise
Exception
(
info
)
from
e
# def attribute_test_trampoline(test_type, attr_type, attr_class, dimensions):
# try:
# if test_type is 'read':
# test_r(attr_type, attr_class, dimensions)
# elif test_type is 'write':
# test_rw(attr_type, attr_class, dimensions)
# {{}}
# ...
# catch as err:
# """Example using extra_info annotation"""
# err.extra_info = "Error for type: {} on class: {} with dimensions: "
# "{}".format(attr_type, attr_class, dimensions)
#
# # Notice how this is not re-raising err, simply raising it
# raise
# """Example using Exception chaining (preferred?)"""
# raise Exception("Error for type: {} on class: {} with dimensions: "
# "{}".format(attr_type, attr_class, dimensions)) from err
"""
List of different types to be used with attributes testing, using any other
Loading