Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
opcua-asyncio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nikola Balog
opcua-asyncio
Commits
8f9bd20e
Commit
8f9bd20e
authored
Jan 16, 2016
by
olivier R-D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_dimensions => get_shape
parent
a7a4acb1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
7 deletions
+7
-7
opcua/ua/uatypes.py
opcua/ua/uatypes.py
+3
-3
tests/tests.py
tests/tests.py
+4
-4
No files found.
opcua/ua/uatypes.py
View file @
8f9bd20e
...
@@ -736,7 +736,7 @@ class Variant(FrozenClass):
...
@@ -736,7 +736,7 @@ class Variant(FrozenClass):
if
self
.
VariantType
is
None
:
if
self
.
VariantType
is
None
:
self
.
VariantType
=
self
.
_guess_type
(
self
.
Value
)
self
.
VariantType
=
self
.
_guess_type
(
self
.
Value
)
if
self
.
Dimensions
is
None
and
type
(
self
.
Value
)
in
(
list
,
tuple
):
if
self
.
Dimensions
is
None
and
type
(
self
.
Value
)
in
(
list
,
tuple
):
dims
=
get_
dimensions
(
self
.
Value
)
dims
=
get_
shape
(
self
.
Value
)
if
len
(
dims
)
>
1
:
if
len
(
dims
)
>
1
:
self
.
Dimensions
=
dims
self
.
Dimensions
=
dims
...
@@ -832,7 +832,7 @@ def _split_list(l, n):
...
@@ -832,7 +832,7 @@ def _split_list(l, n):
return
[
l
[
i
:
i
+
n
]
for
i
in
range
(
0
,
len
(
l
),
n
)]
return
[
l
[
i
:
i
+
n
]
for
i
in
range
(
0
,
len
(
l
),
n
)]
def
flatten_and_get_
dimensions
(
mylist
):
def
flatten_and_get_
shape
(
mylist
):
dims
=
[]
dims
=
[]
dims
.
append
(
len
(
mylist
))
dims
.
append
(
len
(
mylist
))
while
isinstance
(
mylist
[
0
],
(
list
,
tuple
)):
while
isinstance
(
mylist
[
0
],
(
list
,
tuple
)):
...
@@ -853,7 +853,7 @@ def flatten(mylist):
...
@@ -853,7 +853,7 @@ def flatten(mylist):
return
mylist
return
mylist
def
get_
dimensions
(
mylist
):
def
get_
shape
(
mylist
):
dims
=
[]
dims
=
[]
while
isinstance
(
mylist
,
(
list
,
tuple
)):
while
isinstance
(
mylist
,
(
list
,
tuple
)):
dims
.
append
(
len
(
mylist
))
dims
.
append
(
len
(
mylist
))
...
...
tests/tests.py
View file @
8f9bd20e
...
@@ -22,7 +22,7 @@ from opcua.ua import ObjectIds
...
@@ -22,7 +22,7 @@ from opcua.ua import ObjectIds
from
opcua.ua
import
AttributeIds
from
opcua.ua
import
AttributeIds
from
opcua.ua
import
extensionobject_from_binary
from
opcua.ua
import
extensionobject_from_binary
from
opcua.ua
import
extensionobject_to_binary
from
opcua.ua
import
extensionobject_to_binary
from
opcua.ua.uatypes
import
flatten
,
get_
dimensions
,
reshape
from
opcua.ua.uatypes
import
flatten
,
get_
shape
,
reshape
port_num1
=
48510
port_num1
=
48510
port_num2
=
48530
port_num2
=
48530
...
@@ -115,7 +115,7 @@ class Unit(unittest.TestCase):
...
@@ -115,7 +115,7 @@ class Unit(unittest.TestCase):
def
test_flatten
(
self
):
def
test_flatten
(
self
):
l
=
[[[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
]],[[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
]]]
l
=
[[[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
]],[[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
],
[
1.0
,
1.0
,
1.0
,
1.0
]]]
l2
=
flatten
(
l
)
l2
=
flatten
(
l
)
dims
=
get_
dimensions
(
l
)
dims
=
get_
shape
(
l
)
self
.
assertEqual
(
dims
,
[
2
,
3
,
4
])
self
.
assertEqual
(
dims
,
[
2
,
3
,
4
])
self
.
assertNotEqual
(
l
,
l2
)
self
.
assertNotEqual
(
l
,
l2
)
...
@@ -125,12 +125,12 @@ class Unit(unittest.TestCase):
...
@@ -125,12 +125,12 @@ class Unit(unittest.TestCase):
l
=
[[[],
[],
[]],
[[],
[],
[]]]
l
=
[[[],
[],
[]],
[[],
[],
[]]]
l2
=
flatten
(
l
)
l2
=
flatten
(
l
)
dims
=
get_
dimensions
(
l
)
dims
=
get_
shape
(
l
)
self
.
assertEqual
(
dims
,
[
2
,
3
,
0
])
self
.
assertEqual
(
dims
,
[
2
,
3
,
0
])
l
=
[
1
,
2
,
3
,
4
]
l
=
[
1
,
2
,
3
,
4
]
l2
=
flatten
(
l
)
l2
=
flatten
(
l
)
dims
=
get_
dimensions
(
l
)
dims
=
get_
shape
(
l
)
self
.
assertEqual
(
dims
,
[
4
])
self
.
assertEqual
(
dims
,
[
4
])
self
.
assertEqual
(
l
,
l2
)
self
.
assertEqual
(
l
,
l2
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment