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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
wendelin
Commits
d91b19f5
Commit
d91b19f5
authored
Sep 21, 2018
by
Klaus Wölfel
Committed by
Levin Zimmermann
Apr 28, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixup DataArrayView
parent
da087d6c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
4 deletions
+50
-4
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArrayView.py
...lateItem/portal_components/document.erp5.DataArrayView.py
+47
-3
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArrayView.xml
...ateItem/portal_components/document.erp5.DataArrayView.xml
+3
-1
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArrayView.py
View file @
d91b19f5
...
...
@@ -26,8 +26,52 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
from
numpy.lib.recfunctions
import
merge_arrays
from
erp5.component.document.DataArray
import
DataArray
from
numpy
import
dtype
from
numpy.lib.recfunctions
import
merge_arrays
from
wendelin.lib.calc
import
mul
import
sys
class
MergedArray
(
object
):
def
__init__
(
self
,
array_list
):
self
.
array_list
=
array_list
def
__getitem__
(
self
,
idx
):
if
not
(
isinstance
,
idx
,
slice
):
raise
TypeError
(
"Only slice index is supported."
)
if
idx
.
start
==
0
and
idx
.
stop
==
sys
.
maxint
:
raise
ValueError
(
"Only partial slice is supported"
)
return
merge_arrays
([
a
[
0
:
len
(
self
)][
idx
]
for
a
in
self
.
array_list
],
flatten
=
True
)
# ~~~ ndarray-like attributes
@
property
def
data
(
self
):
raise
TypeError
(
"Direct access to data for BigArray is forbidden"
)
@
property
def
strides
(
self
):
return
(
self
.
itemsize
,)
@
property
def
dtype
(
self
):
return
dtype
(
reduce
(
lambda
x
,
y
:
[(
n
,
x
.
dtype
.
fields
[
n
][
0
])
for
n
in
x
.
dtype
.
names
]
+
[(
n
,
y
.
dtype
.
fields
[
n
][
0
])
for
n
in
y
.
dtype
.
names
],
self
.
array_list
))
@
property
def
shape
(
self
):
return
(
min
((
len
(
a
)
for
a
in
self
.
array_list
)),)
@
property
def
size
(
self
):
return
mul
(
self
.
shape
)
def
__len__
(
self
):
# lengths of the major axis
return
self
.
shape
[
0
]
@
property
def
itemsize
(
self
):
return
self
.
dtype
.
itemsize
@
property
def
nbytes
(
self
):
return
self
.
itemsize
*
self
.
size
@
property
def
ndim
(
self
):
return
len
(
self
.
shape
)
class
DataArrayView
(
DataArray
):
"""
...
...
@@ -44,7 +88,7 @@ class DataArrayView(DataArray):
"""
Get numpy view of views defined in Data Array View Lines.
"""
line_list
=
[(
l
.
getIntIndex
(),
l
)
for
l
in
self
.
objectValues
(
portal_type
=
"Data Array View Line"
)]
line_list
=
[(
l
.
getIntIndex
(),
l
.
getArray
()
)
for
l
in
self
.
objectValues
(
portal_type
=
"Data Array View Line"
)]
if
not
line_list
:
return
None
return
merge_arrays
([
l
[
1
].
getArray
()
for
l
in
sorted
(
line_list
)],
flatten
=
True
)
return
MergedArray
([
l
[
1
]
for
l
in
sorted
(
line_list
)]
)
\ No newline at end of file
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArrayView.xml
View file @
d91b19f5
...
...
@@ -45,7 +45,9 @@
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
<tuple>
<string>
W: 81, 29: Redefining name \'dtype\' from outer scope (line 30) (redefined-outer-name)
</string>
</tuple>
</value>
</item>
<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