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
isaak yansane-sisk
wendelin
Commits
d7693e87
Commit
d7693e87
authored
Jul 02, 2015
by
Ivan Tyagov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement array slicing in its most simple list alike form + test of it.
parent
81c688e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
3 deletions
+32
-3
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
...TemplateItem/portal_components/document.erp5.DataArray.py
+10
-2
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
...tTemplateItem/portal_components/test.erp5.testWendelin.py
+22
-1
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
View file @
d7693e87
...
...
@@ -57,7 +57,7 @@ class DataArray(BigFile):
"""
array
=
ZBigArray
(
shape
,
dtype
)
self
.
_setArray
(
array
)
def
getArray
(
self
,
default
=
None
):
"""
Get numpy array value.
...
...
@@ -73,4 +73,12 @@ class DataArray(BigFile):
# 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
transaction
.
commit
()
def
getArraySlice
(
self
,
start
,
end
):
"""
Implement array slicing in its most simple list alike form.
Any other advanced slicing techniques currently possible by getting
array reference directly.
"""
return
self
.
getArray
()[
start
:
end
]
\ No newline at end of file
bt5/erp5_wendelin/TestTemplateItem/portal_components/test.erp5.testWendelin.py
View file @
d7693e87
...
...
@@ -258,4 +258,25 @@ context.activate().DataStream_readChunkListAndTransform( \
# resize Zbig Array
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
self
.
assertNotEquals
(
pure_numpy_array
.
shape
,
persistent_zbig_array
.
shape
)
# get array slice (fails)
data_array
=
self
.
portal
.
data_array_module
.
newContent
(
\
portal_type
=
'Data Array'
)
shape
=
(
1000
,)
data_array
.
initArray
(
shape
,
np
.
uint8
)
self
.
tic
()
persistent_zbig_array
=
data_array
.
getArray
()
new_array
=
np
.
arange
(
1000
)
new_array
.
resize
(
shape
)
self
.
assertEquals
(
new_array
.
shape
,
persistent_zbig_array
.
shape
)
persistent_zbig_array
[:,]
=
new_array
self
.
tic
()
self
.
assertTrue
(
np
.
array_equal
(
data_array
.
getArraySlice
(
0
,
100
),
\
new_array
[:
100
]))
\ No newline at end of file
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