Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
klaus_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
Eteri
klaus_wendelin
Commits
c850a14d
Commit
c850a14d
authored
May 29, 2015
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More testing and API extension.
parent
e101ff9c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
18 deletions
+41
-18
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
...TemplateItem/portal_components/document.erp5.DataArray.py
+16
-1
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+23
-17
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.xml
...TemplateItem/portal_components/test.erp5.testWendelin.xml
+2
-0
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
View file @
c850a14d
...
...
@@ -29,6 +29,8 @@
from
AccessControl
import
ClassSecurityInfo
from
Products.ERP5Type
import
Permissions
,
PropertySheet
from
Products.ERP5.Document.BigFile
import
BigFile
from
wendelin.bigarray.array_zodb
import
ZBigArray
import
transaction
class
DataArray
(
BigFile
):
"""
...
...
@@ -46,10 +48,23 @@ class DataArray(BigFile):
# Declarative properties
property_sheets
=
(
PropertySheet
.
CategoryCore
,
PropertySheet
.
SortIndex
,
PropertySheet
.
DataArray
)
def
initArray
(
self
,
shape
,
dtype
):
"""
Initialise array.
"""
array
=
ZBigArray
(
shape
,
dtype
)
self
.
_setArray
(
array
)
def
_setArray
(
self
,
value
):
"""
Set numpy array to this ERP5 Data Array.
"""
self
.
array
=
value
\ No newline at end of file
self
.
array
=
value
# ZBigArray requirement: before we can compute it (with subobject
# .zfile) have to be made explicitly known to connection or current
# transaction committed (XXX: impossible to use as raises ConflictErrors)
transaction
.
commit
()
\ No newline at end of file
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
c850a14d
...
...
@@ -28,7 +28,7 @@
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
import
msgpack
import
numpy
as
np
import
transaction
#
import transaction
class
Test
(
ERP5TypeTestCase
):
"""
...
...
@@ -99,25 +99,31 @@ class Test(ERP5TypeTestCase):
data_array
=
self
.
portal
.
data_array_module
.
newContent
(
\
portal_type
=
'Data Array'
)
array
=
ZBigArray
((
60
,
60
),
np
.
uint8
)
# ZBigArray requirement: before we can compute it (with subobject
# .zfile) have to be made explicitly known to connection or current
# transaction committed
transaction
.
commit
()
data_array
.
setArray
(
array
)
data_array
.
initArray
((
3
,
3
),
np
.
uint8
)
self
.
tic
()
# test array stored and we
t
eturn ZBig Array instance
# test array stored and we
r
eturn ZBig Array instance
persistent_zbig_array
=
data_array
.
getArray
()
self
.
assertEqual
(
ZBigArray
,
persistent_zbig_array
.
__class__
)
self
.
assertEquals
(
array
,
persistent_zbig_array
)
# try to resize it
#pure_numpy_array = persistent_zbig_array[:,:] # ZBigArray -> ndarray view of it
#pure_numpy_array = np.resize(pure_numpy_array, (100,100))
#self.assertNotEquals(pure_numpy_array.shape, persistent_zbig_array.shape)
# try to resize its numpy "view" and check that persistent one is not saved
# as these are differerent objects
pure_numpy_array
=
persistent_zbig_array
[:,:]
# ZBigArray -> ndarray view of it
pure_numpy_array
=
np
.
resize
(
pure_numpy_array
,
(
4
,
4
))
self
.
assertNotEquals
(
pure_numpy_array
.
shape
,
persistent_zbig_array
.
shape
)
# test copy numpy -> wendelin but first resize persistent one (add new one)
data_array
.
initArray
((
4
,
4
),
np
.
uint8
)
persistent_zbig_array
=
data_array
.
getArray
()
rows
=
[
0
,
1
]
cols
=
[
2
,
2
]
new_array
=
np
.
arange
(
1
,
17
).
reshape
((
4
,
4
))
persistent_zbig_array
[:,:]
=
new_array
self
.
assertEquals
(
new_array
.
shape
,
persistent_zbig_array
.
shape
)
# (enable when new wendelin.core released as it can kill system)
#self.assertTrue(np.array_equal(a, persistent_zbig_array))
# resize Zbig Array
#persistent_zbig_array.resize(100,100)
\ No newline at end of file
# resize Zbig Array (enable when new wendelin.core released as it can kill system)
#persistent_zbig_array = np.resize(persistent_zbig_array, (100,100))
#self.assertNotEquals(pure_numpy_array.shape, persistent_zbig_array.shape)
\ No newline at end of file
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.xml
View file @
c850a14d
...
...
@@ -48,6 +48,8 @@
<tuple>
<string>
W: 53, 4: Unused variable \'scipy\' (unused-variable)
</string>
<string>
W: 54, 4: Unused variable \'sklearn\' (unused-variable)
</string>
<string>
W:118, 4: Unused variable \'rows\' (unused-variable)
</string>
<string>
W:119, 4: Unused variable \'cols\' (unused-variable)
</string>
</tuple>
</value>
</item>
...
...
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