From da147918385e4e162a7d1f97f8dd59b3d4519561 Mon Sep 17 00:00:00 2001 From: Rama Vasudevan Date: Thu, 9 Nov 2023 12:17:02 -0500 Subject: [PATCH] fix loop fit --- BGlib/be/analysis/be_loop_fitter.py | 4 ++-- tests/be/test_be_module.py | 30 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 tests/be/test_be_module.py diff --git a/BGlib/be/analysis/be_loop_fitter.py b/BGlib/be/analysis/be_loop_fitter.py index 356fffa..8e0c9eb 100644 --- a/BGlib/be/analysis/be_loop_fitter.py +++ b/BGlib/be/analysis/be_loop_fitter.py @@ -351,7 +351,7 @@ def _read_data_chunk(self): 0] else: this_forc_spec_inds = np.ones( - shape=self.h5_main.h5_spec_inds.shape[1], dtype=np.bool) + shape=self.h5_main.h5_spec_inds.shape[1], dtype=bool) if self._num_forcs: this_forc_dc_vec = get_unit_values( @@ -495,7 +495,7 @@ def _read_guess_chunk(self): np.where(self._h5_guess.h5_spec_inds[forc_pos] == forc_ind)[0] else: this_forc_spec_inds = np.ones( - shape=self._h5_guess.h5_spec_inds.shape[1], dtype=np.bool) + shape=self._h5_guess.h5_spec_inds.shape[1], dtype=bool) this_forc_2d = self._guess[:, this_forc_spec_inds] if self.verbose and self.mpi_rank == 0: diff --git a/tests/be/test_be_module.py b/tests/be/test_be_module.py new file mode 100644 index 0000000..bf5797a --- /dev/null +++ b/tests/be/test_be_module.py @@ -0,0 +1,30 @@ +import unittest +import sys +import os +sys.path.append("../BGlib/") +import BGlib.be as belib +import pyUSID as usid +import h5py + +class TestLoadDataset(unittest.TestCase): + + def test_bepfm_dataset(self): + #this file is actually a corrupted BEPFM file for which the translator has an auto fix + #So we need to download the original file, see if the following works, then delete + #TODO: Host hte original file somewhere, use wget + + input_file_path = r'/Users/rvv/Downloads/PTO_a32/BEPFM_1um_afterBEPS_0039.h5' + (data_dir, filename) = os.path.split(input_file_path) + # No translation here + h5_path = input_file_path + force = False # Set this to true to force patching of the datafile. + tl = belib.translators.LabViewH5Patcher() + tl.translate(h5_path, force_patch=force) + h5_file = h5py.File(h5_path, 'r+') + h5_main = usid.hdf_utils.find_dataset(h5_file, 'Raw_Data')[0] + #Let's see if we get the right type of file back... + assert type(h5_main) == usid.io.usi_data.USIDataset + + def test_values_as_length(self): + print("OK") + \ No newline at end of file