Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
LOFAR Station Client
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
LOFAR2.0
LOFAR Station Client
Commits
7f674955
Commit
7f674955
authored
Sep 27, 2022
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-882
: Fix linting
parent
ace8d1f3
No related branches found
No related tags found
1 merge request
!4
Added custom LofarDeviceProxy to enhance support for high-dimensional arrays in attribtues
Pipeline
#36548
failed
Sep 27, 2022
Stage: lint
Stage: test
Stage: package
Stage: integration
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lofar_station_client/devices.py
+10
-3
10 additions, 3 deletions
lofar_station_client/devices.py
tests/test_devices.py
+13
-24
13 additions, 24 deletions
tests/test_devices.py
with
23 additions
and
27 deletions
lofar_station_client/devices.py
+
10
−
3
View file @
7f674955
...
...
@@ -8,6 +8,7 @@ import numpy
from
tango
import
DeviceProxy
from
tango
import
ExtractAs
class
LofarDeviceProxy
(
DeviceProxy
):
"""
A LOFAR-specific tango.DeviceProxy that provides
a richer experience.
"""
...
...
@@ -20,10 +21,14 @@ class LofarDeviceProxy(DeviceProxy):
@lru_cache
()
def
get_attribute_shape
(
self
,
name
):
# "format" property describes actual dimensions as a tuple (x, y, z, ...),
# so reshape the value accordingly.
"""
Get the shape of the requested attribute, as a tuple.
"""
config
=
self
.
get_attribute_config
(
name
)
if
config
.
format
and
config
.
format
[
0
]
==
"
(
"
:
# For >2D arrays, the "format" property describes actual
# the dimensions as a tuple (x, y, z, ...),
# so reshape the value accordingly.
shape
=
ast
.
literal_eval
(
config
.
format
)
elif
config
.
max_dim_y
>
0
:
# 2D array
...
...
@@ -61,7 +66,9 @@ class LofarDeviceProxy(DeviceProxy):
value
=
numpy
.
array
(
value
)
if
value
.
shape
!=
shape
:
raise
ValueError
(
f
"
Invalid shape. Given:
{
value
.
shape
}
Expected:
{
shape
}
"
)
raise
ValueError
(
f
"
Invalid shape. Given:
{
value
.
shape
}
Expected:
{
shape
}
"
)
if
len
(
shape
)
>
2
:
# >2D arrays collapse into 2D
...
...
This diff is collapsed.
Click to expand it.
tests/test_devices.py
+
13
−
24
View file @
7f674955
...
...
@@ -17,22 +17,12 @@ class MyDevice(Device):
access
=
AttrWriteType
.
READ_WRITE
,
)
scalar
=
attribute
(
dtype
=
bool
,
access
=
AttrWriteType
.
READ_WRITE
)
scalar
=
attribute
(
dtype
=
bool
,
access
=
AttrWriteType
.
READ_WRITE
)
spectrum
=
attribute
(
dtype
=
(
bool
,),
max_dim_x
=
2
,
access
=
AttrWriteType
.
READ_WRITE
)
spectrum
=
attribute
(
dtype
=
(
bool
,),
max_dim_x
=
2
,
access
=
AttrWriteType
.
READ_WRITE
)
image
=
attribute
(
dtype
=
((
bool
,),),
max_dim_x
=
2
,
max_dim_y
=
3
,
access
=
AttrWriteType
.
READ_WRITE
dtype
=
((
bool
,),),
max_dim_x
=
2
,
max_dim_y
=
3
,
access
=
AttrWriteType
.
READ_WRITE
)
def
init_device
(
self
):
...
...
@@ -110,7 +100,6 @@ class LofarDeviceProxyTest(base.TestCase):
self
.
assertEqual
((
3
,
2
),
value
.
shape
)
self
.
assertEqual
(
numpy
.
bool_
,
type
(
value
[
0
,
0
]))
def
test_write_image
(
self
):
self
.
proxy
.
image
=
[[
True
,
False
]]
*
3
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment