Skip to content
GitLab
Explore
Sign in
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
Commits
d487f383
Commit
d487f383
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-244
: Dim (1,0) is by definition a scalar according to PyTango. Honour this.
parent
2892211f
No related branches found
No related tags found
1 merge request
!56
L2SS-244: Expose the SSTs in MPs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/util/attribute_wrapper.py
+14
-9
14 additions, 9 deletions
devices/util/attribute_wrapper.py
with
14 additions
and
9 deletions
devices/util/attribute_wrapper.py
+
14
−
9
View file @
d487f383
...
...
@@ -14,18 +14,20 @@ class attribute_wrapper(attribute):
Wraps all the attributes in a wrapper class to manage most of the redundant code behind the scenes
"""
def
__init__
(
self
,
comms_annotation
=
None
,
datatype
=
None
,
dims
=
None
,
access
=
AttrWriteType
.
READ
,
init_value
=
None
,
**
kwargs
):
def
__init__
(
self
,
comms_annotation
=
None
,
datatype
=
None
,
dims
=
(
1
,)
,
access
=
AttrWriteType
.
READ
,
init_value
=
None
,
**
kwargs
):
"""
wraps around the tango Attribute class. Provides an easier interface for 1d or 2d arrays. Also provides a way to abstract
managing the communications interface.
comms_annotation: data passed along to the attribute. can be given any form of data. handling is up to client implementation
datatype: any numpy datatype
dims: dimensions of the attribute as a tuple, or
None
for a scalar.
dims: dimensions of the attribute as a tuple, or
(1,)
for a scalar.
init_value: value
"""
# ensure the type is a numpy array
# ensure the type is a numpy array.
# see also https://pytango.readthedocs.io/en/stable/server_api/server.html?highlight=devlong#module-tango.server for
# more details about type conversion Python/numpy -> PyTango
if
"
numpy
"
not
in
str
(
datatype
)
and
datatype
!=
str
:
raise
TypeError
(
"
Attribute needs to be a Tango-supported numpy or str type, but has type
\"
%s
\"
"
%
(
datatype
,))
...
...
@@ -33,7 +35,7 @@ class attribute_wrapper(attribute):
self
.
numpy_type
=
datatype
# tango changes our attribute to their representation (E.g numpy.int64 becomes "DevLong64")
self
.
init_value
=
init_value
max_dim_y
=
0
is_scalar
=
dims
==
(
1
,)
# tango doesn't recognise numpy.str_, for consistencies sake we convert it here and hide this from the top level
# NOTE: discuss, idk if this is an important detail somewhere else
...
...
@@ -41,8 +43,12 @@ class attribute_wrapper(attribute):
datatype
=
str
# check if not scalar
if
isinstance
(
dims
,
tuple
):
if
is_scalar
:
# scalar, just set the single dimension.
# Tango defines a scalar as having dimensions (1,0), see https://pytango.readthedocs.io/en/stable/server_api/attribute.html
max_dim_x
=
1
max_dim_y
=
0
else
:
# get first dimension
max_dim_x
=
dims
[
0
]
...
...
@@ -54,9 +60,8 @@ class attribute_wrapper(attribute):
max_dim_y
=
dims
[
1
]
# wrap the datatype tuple in another tuple for 2d arrays/images
datatype
=
(
datatype
,)
else
:
# scalar, just set the single dimension
max_dim_x
=
1
else
:
max_dim_y
=
0
if
access
==
AttrWriteType
.
READ_WRITE
:
"""
if the attribute is of READ_WRITE type, assign the RW and write function to it
"""
...
...
This diff is collapsed.
Click to expand it.
Jan David Mol
@mol
mentioned in commit
777a55cd
·
3 years ago
mentioned in commit
777a55cd
mentioned in commit 777a55cd2c0c14e74a9d46831b99332530bb0a10
Toggle commit list
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