Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin
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
0
Merge Requests
0
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
Rafael Monnerat
wendelin
Commits
cfd3e9c6
Commit
cfd3e9c6
authored
Jun 08, 2022
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_wendelin: Add test for numpy <> wendelin conversion
parent
da3981df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
1 deletion
+33
-1
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+33
-1
No files found.
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
cfd3e9c6
...
@@ -28,10 +28,12 @@
...
@@ -28,10 +28,12 @@
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
from
wendelin.bigarray.array_zodb
import
ZBigArray
from
wendelin.bigarray.array_zodb
import
ZBigArray
from
cStringIO
import
StringIO
from
cStringIO
import
StringIO
import
binascii
import
msgpack
import
msgpack
import
numpy
as
np
import
numpy
as
np
import
string
import
string
import
random
import
random
import
struct
import
urllib
import
urllib
...
@@ -523,4 +525,34 @@ class Test(ERP5TypeTestCase):
...
@@ -523,4 +525,34 @@ class Test(ERP5TypeTestCase):
)
)
zbigarray
=
temporary_data_array
.
initArray
(
shape
=
ndarray
.
shape
,
dtype
=
ndarray
.
dtype
)
zbigarray
=
temporary_data_array
.
initArray
(
shape
=
ndarray
.
shape
,
dtype
=
ndarray
.
dtype
)
zbigarray
.
append
(
ndarray
)
zbigarray
.
append
(
ndarray
)
self
.
assertTrue
(
np
.
array_equal
(
zbigarray
[
2
:],
ndarray
))
self
.
assertTrue
(
np
.
array_equal
(
zbigarray
[
2
:],
ndarray
))
\ No newline at end of file
def
test_12_numpyWendelinConversion
(
self
):
"""
Test if conversion from numpy arrays to wendelin data works.
"""
portal
=
self
.
portal
ndarray
=
np
.
array
([[
0
,
1
],
[
2
,
3
]])
wendelin_data
=
portal
.
Base_numpyToWendelinData
(
ndarray
)
reconverted_ndarray
=
portal
.
Base_wendelinDataToNumpy
(
wendelin_data
)
self
.
assertIsInstance
(
wendelin_data
,
bytes
)
# Check for header
self
.
assertEqual
(
wendelin_data
[:
4
],
b'
\
x92
WEN'
)
# Test checksum
checksum
=
struct
.
unpack
(
'<i'
,
wendelin_data
[
6
:
10
])[
0
]
self
.
assertEqual
(
checksum
,
binascii
.
crc32
(
wendelin_data
[
10
:]))
# Test inverse conversion works
self
.
assertTrue
(
np
.
array_equal
(
ndarray
,
reconverted_ndarray
))
self
.
assertTrue
(
np
.
array_equal
(
portal
.
Base_wendelinTextToNumpy
(
"kldFTgABq96QqZNOVU1QWQEARgB7J2Rlc2NyJzogJzxmOCcsICdmb3J0cmFuX29yZGVyJzogRmFsc2UsICdzaGFwZSc6ICgwLCksIH0gICAgICAgICAgICAK="
),
np
.
array
([]),
)
)
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