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
4459a215
Commit
4459a215
authored
Dec 17, 2019
by
Eteri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add funcionality to get array slice with start and stop dates
parent
31c27c22
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
8 deletions
+27
-8
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
...TemplateItem/portal_components/document.erp5.DataArray.py
+24
-6
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.xml
...emplateItem/portal_components/document.erp5.DataArray.xml
+3
-2
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
View file @
4459a215
...
@@ -149,12 +149,30 @@ class DataArray(BigFile):
...
@@ -149,12 +149,30 @@ class DataArray(BigFile):
# chunk out of our data.
# chunk out of our data.
# convert ranges from bytes to array indices
# convert ranges from bytes to array indices
slice_index
=
REQUEST
.
get
(
'slice_index'
,
None
)
slice_index
=
REQUEST
.
get
(
'slice_index'
,
None
)
start_date
=
REQUEST
.
get
(
'start_date'
,
None
)
stop_date
=
REQUEST
.
get
(
'stop_date'
,
None
)
if
slice_index
is
not
None
or
(
start_date
is
not
None
and
stop_date
is
not
None
):
if
slice_index
is
not
None
:
if
slice_index
is
not
None
:
slice_index_list
=
[]
slice_index_list
=
[]
for
index
in
slice_index
:
for
index
in
slice_index
:
slice_index_list
.
append
(
slice
(
index
.
get
(
'start'
),
slice_index_list
.
append
(
slice
(
index
.
get
(
'start'
),
index
.
get
(
'stop'
),
index
.
get
(
'stop'
),
index
.
get
(
'step'
)))
index
.
get
(
'step'
)))
elif
start_date
is
not
None
and
stop_date
is
not
None
:
import
numpy
as
np
import
pandas
as
pd
start_date_vector
=
self
.
getArray
()[:][
'start_date'
]
stop_date_vector
=
self
.
getArray
()[:][
'stop_date'
]
valid_start_idx
=
np
.
where
(
start_date_vector
>=
np
.
datetime64
(
start_date
))[
0
]
valid_stop_idx
=
np
.
where
(
stop_date_vector
<=
np
.
datetime64
(
stop_date
))[
0
]
if
len
(
valid_start_idx
)
!=
0
and
len
(
valid_stop_idx
)
!=
0
:
start_index
=
valid_start_idx
[
start_date_vector
[
valid_start_idx
].
argmin
()]
stop_index
=
valid_stop_idx
[
stop_date_vector
[
valid_stop_idx
].
argmax
()]
slice_index_list
=
[
slice
(
start_index
,
stop_index
+
1
)]
else
:
slice_index_list
=
[
slice
(
0
,
0
)]
list_index
=
REQUEST
.
get
(
'list_index'
,
None
)
list_index
=
REQUEST
.
get
(
'list_index'
,
None
)
if
list_index
is
not
None
:
if
list_index
is
not
None
:
RESPONSE
.
write
(
self
.
getArray
()[
tuple
(
slice_index_list
)][
list_index
].
tobytes
())
RESPONSE
.
write
(
self
.
getArray
()[
tuple
(
slice_index_list
)][
list_index
].
tobytes
())
...
...
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.xml
View file @
4459a215
...
@@ -47,8 +47,9 @@
...
@@ -47,8 +47,9 @@
<value>
<value>
<tuple>
<tuple>
<string>
W:133, 42: Redefining built-in \'format\' (redefined-builtin)
</string>
<string>
W:133, 42: Redefining built-in \'format\' (redefined-builtin)
</string>
<string>
W:165, 4: Redefining built-in \'range\' (redefined-builtin)
</string>
<string>
W:183, 4: Redefining built-in \'range\' (redefined-builtin)
</string>
<string>
W:192, 10: No exception type(s) specified (bare-except)
</string>
<string>
W:210, 10: No exception type(s) specified (bare-except)
</string>
<string>
W:163, 8: Unused variable \'pd\' (unused-variable)
</string>
</tuple>
</tuple>
</value>
</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