Skip to content

Commit

Permalink
adding str typing to h5save_out input
Browse files Browse the repository at this point in the history
  • Loading branch information
darianyang committed Feb 29, 2024
1 parent 1e76689 commit 9a09fe4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions wedap/h5_pdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ def __init__(self, h5="west.h5", data_type=None, Xname="pcoord", Xindex=0, Yname
self.Xsave_name = Xsave_name
self.Ysave_name = Ysave_name
self.Zsave_name = Zsave_name
# if H5save_out is not None:
# shutil.copyfile(self.h5_name, H5save_out)
# self.H5save_out = h5py.File(H5save_out, "r+")
if H5save_out is not None:
shutil.copyfile(self.h5_name, str(H5save_out))
self.H5save_out = h5py.File(H5save_out, "r+")

# raw data processing function
# TODO: allow for 2-3 functions as tuple input, right now one function only
Expand Down Expand Up @@ -534,7 +534,7 @@ def _new_weights_from_skip_basis(self):
Returns
-------
self.weights : array
new_weights : array
Updated weight array with zero values for skipped basis states.
"""
# TODO: doesn't work with --first-iter
Expand Down Expand Up @@ -810,6 +810,10 @@ def w_succ(self):
TODO eventually can use this to plot pdist of succ only trajs
note that I would have to norm by the overall pmax (not just succ pmax)
Could have this be an optional feature.
Returns
-------
succ : list of tuples (iter,wlk)
"""
succ = []
for iter in tqdm(range(self.first_iter, self.last_iter + 1),
Expand Down Expand Up @@ -1307,8 +1311,8 @@ def make_new_h5(self, new_weights=None):
Updated weight values, e.g. from skip_basis or succ_only.
"""
# make copy of h5 file and open copy
shutil.copyfile(self.h5_name, self.H5save_out)
self.H5save_out = h5py.File(self.H5save_out, "r+")
# shutil.copyfile(self.h5_name, self.H5save_out)
# self.H5save_out = h5py.File(self.H5save_out, "r+")
# replace weights
if new_weights is not None:
for idx, weight in enumerate(new_weights):
Expand Down

0 comments on commit 9a09fe4

Please sign in to comment.