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
5
Merge Requests
5
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
nexedi
wendelin
Commits
6853aae5
Commit
6853aae5
authored
Dec 17, 2019
by
Eteri
Committed by
Levin Zimmermann
Feb 01, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add funcionality to get array slice with start and stop dates
parent
d303997f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
6 deletions
+24
-6
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
...TemplateItem/portal_components/document.erp5.DataArray.py
+24
-6
No files found.
bt5/erp5_wendelin/DocumentTemplateItem/portal_components/document.erp5.DataArray.py
View file @
6853aae5
...
...
@@ -160,13 +160,31 @@ class DataArray(BigFile):
# chunk out of our data.
# convert ranges from bytes to array indices
slice_index
=
REQUEST
.
get
(
'slice_index'
,
None
)
if
slice_index
is
not
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
):
RESPONSE
.
setHeader
(
"Content-Type"
,
"application/octet-stream"
)
if
slice_index
is
not
None
:
slice_index_list
=
[]
for
index
in
slice_index
:
slice_index_list
.
append
(
slice
(
index
.
get
(
'start'
),
index
.
get
(
'stop'
),
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
)
if
list_index
is
not
None
:
RESPONSE
.
write
(
self
.
getArray
()[
tuple
(
slice_index_list
)][
list_index
].
tobytes
())
...
...
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