Skip to content
Snippets Groups Projects
Commit add7ee7d authored by Stefan Reck's avatar Stefan Reck
Browse files

cleanup concatenate.py

parent b1ab82f4
No related branches found
No related tags found
1 merge request!23Jagged graph
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"\nElapsed time: {elapsed_time/60:.2f} min "
f"({elapsed_time/len(self.input_files):.2f} 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.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment