Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
OrcaSong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Machine Learning
OrcaSong
Commits
add7ee7d
Commit
add7ee7d
authored
3 years ago
by
Stefan Reck
Browse files
Options
Downloads
Patches
Plain Diff
cleanup concatenate.py
parent
b1ab82f4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!23
Jagged graph
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
orcasong/tools/concatenate.py
+2
-14
2 additions, 14 deletions
orcasong/tools/concatenate.py
with
2 additions
and
14 deletions
orcasong/tools/concatenate.py
+
2
−
14
View file @
add7ee7d
import
os
import
time
import
h5py
import
numpy
as
np
import
warnings
...
...
@@ -45,8 +44,6 @@ class FileConcatenator:
self
.
comptopts
.
update
(
comptopts_update
)
print
(
"
\n
"
.
join
([
f
"
{
k
}
:
\t
{
v
}
"
for
k
,
v
in
self
.
comptopts
.
items
()]))
self
.
_modify_folder
=
False
@classmethod
def
from_list
(
cls
,
list_file
,
n_files
=
None
,
**
kwargs
):
"""
...
...
@@ -90,7 +87,7 @@ class FileConcatenator:
print
(
f
'
Processing file
{
input_file_nmbr
+
1
}
/
'
f
'
{
len
(
self
.
input_files
)
}
:
{
input_file
}
'
)
with
h5py
.
File
(
input_file
,
'
r
'
)
as
f_in
:
self
.
_conc_file
(
f_in
,
f_out
,
input_file
,
input_file_nmbr
)
self
.
_conc_file
(
f_in
,
f_out
,
input_file_nmbr
)
f_out
.
flush
()
elapsed_time
=
time
.
time
()
-
start_time
...
...
@@ -107,7 +104,7 @@ class FileConcatenator:
f
"
\n
Elapsed time:
{
elapsed_time
/
60
:
.
2
f
}
min
"
f
"
(
{
elapsed_time
/
len
(
self
.
input_files
)
:
.
2
f
}
s per file)
"
)
def
_conc_file
(
self
,
f_in
,
f_out
,
input_file
,
input_file_nmbr
):
def
_conc_file
(
self
,
f_in
,
f_out
,
input_file_nmbr
):
"""
Conc one file to the output.
"""
for
dset_name
in
f_in
:
if
is_folder_ignored
(
dset_name
):
...
...
@@ -131,12 +128,6 @@ class FileConcatenator:
# add 1 because the group_ids start with 0
folder_data
[
"
group_id
"
]
+=
f_out
[
dset_name
][
last_index
][
"
group_id
"
]
+
1
if
self
.
_modify_folder
:
data_mody
=
self
.
_modify
(
input_file
,
folder_data
,
dset_name
)
if
data_mody
is
not
None
:
folder_data
=
data_mody
if
input_file_nmbr
==
0
:
# first file; create the dataset
dset_shape
=
(
self
.
cumu_rows
[
dset_name
][
-
1
],)
+
folder_data
.
shape
[
1
:]
...
...
@@ -158,9 +149,6 @@ class FileConcatenator:
self
.
cumu_rows
[
dset_name
][
input_file_nmbr
+
1
]
]
=
folder_data
def
_modify
(
self
,
input_file
,
folder_data
,
folder_name
):
raise
NotImplementedError
def
_get_cumu_rows
(
self
,
input_files
):
"""
Checks if all the files can be safely concatenated to the first one.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment