You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class dircmp(filecmp.dircmp):
"""
Compare the content of dir1 and dir2. In contrast with filecmp.dircmp, this
subclass compares the content of files with the same path.
"""
def phase3(self):
"""
Find out differences between common files.
Ensure we are using content comparison with shallow=False.
"""
fcomp = filecmp.cmpfiles(self.left, self.right, self.common_files,
shallow=False)
self.same_files, self.diff_files, self.funny_files = fcomp
def compare_dirs(dir1: Path, dir2: Path):
"""
Compare two directory trees content.
Return False if they differ, True is they are the same.
"""
compared = dircmp(dir1, dir2)
if (compared.left_only or compared.right_only or compared.diff_files
or compared.funny_files):
return False
for subdir in compared.common_dirs:
if not compare_dirs(dir1 / subdir, dir2 / subdir):
return False
return True
def _extract_from_h5_by_index(filehandle, ev_start_idx: int, ev_end_idx: int):
events = filehandle['events']
x = events['x']
y = events['y']
p = events['p']
t = events['t']
def h5_file_to_dict(h5_file: Path):
with h5py.File(h5_file) as fh:
return {k: fh[k][()] for k in fh.keys()}
def yaml_file_to_dict(yaml_file: Path):
with yaml_file.open() as fh:
return yaml.load(fh, Loader=yaml.UnsafeLoader)
##############################################################
Subject: Request for Solutions to Missing Functions in the Code
Dear Daniel,
I hope this message finds you well.
I have encountered an issue while working with the code, as it appears to be missing the following functions:
extract_from_h5_by_timewindow
extract_image_by_index
load_start_and_end_time
Could you kindly provide some guidance or solutions to address this issue? I would greatly appreciate your help and look forward to your response.
Thank you in advance for your time and assistance.
Best regards,
[Eric nian]
The text was updated successfully, but these errors were encountered:
import yaml
import h5py
import numpy as np
import math
from pathlib import Path
import filecmp
from https://stackoverflow.com/questions/4187564/recursively-compare-two-directories-to-ensure-they-have-the-same-files-and-subdi
class dircmp(filecmp.dircmp):
"""
Compare the content of dir1 and dir2. In contrast with filecmp.dircmp, this
subclass compares the content of files with the same path.
"""
def phase3(self):
"""
Find out differences between common files.
Ensure we are using content comparison with shallow=False.
"""
fcomp = filecmp.cmpfiles(self.left, self.right, self.common_files,
shallow=False)
self.same_files, self.diff_files, self.funny_files = fcomp
def compare_dirs(dir1: Path, dir2: Path):
"""
Compare two directory trees content.
Return False if they differ, True is they are the same.
"""
compared = dircmp(dir1, dir2)
if (compared.left_only or compared.right_only or compared.diff_files
or compared.funny_files):
return False
for subdir in compared.common_dirs:
if not compare_dirs(dir1 / subdir, dir2 / subdir):
return False
return True
def _extract_from_h5_by_index(filehandle, ev_start_idx: int, ev_end_idx: int):
events = filehandle['events']
x = events['x']
y = events['y']
p = events['p']
t = events['t']
def get_num_events(h5file):
with h5py.File(str(h5file), 'r') as h5f:
return len(h5f['events/t'])
def extract_from_h5_by_index(h5file, ev_start_idx: int, ev_end_idx: int):
with h5py.File(str(h5file), 'r') as h5f:
return _extract_from_h5_by_index(h5f, ev_start_idx, ev_end_idx)
def extract_from_h5_by_timewindow(h5file, t_min_us: int, t_max_us: int):
with h5py.File(str(h5file), 'r') as h5f:
ms2idx = np.asarray(h5f['ms_to_idx'], dtype='int64')
t_offset = h5f['t_offset'][()]
def h5_file_to_dict(h5_file: Path):
with h5py.File(h5_file) as fh:
return {k: fh[k][()] for k in fh.keys()}
def yaml_file_to_dict(yaml_file: Path):
with yaml_file.open() as fh:
return yaml.load(fh, Loader=yaml.UnsafeLoader)
##############################################################
Subject: Request for Solutions to Missing Functions in the Code
Dear Daniel,
I hope this message finds you well.
I have encountered an issue while working with the code, as it appears to be missing the following functions:
extract_from_h5_by_timewindow
extract_image_by_index
load_start_and_end_time
Could you kindly provide some guidance or solutions to address this issue? I would greatly appreciate your help and look forward to your response.
Thank you in advance for your time and assistance.
Best regards,
[Eric nian]
The text was updated successfully, but these errors were encountered: