Skip to content

Commit 3d7d9d7

Browse files
authored
Merge pull request #44 from bsavitzky/dev
Fixes bug in check_version from v0.5 update
2 parents c730388 + 11c50fd commit 3d7d9d7

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

py4DSTEM/file/io/filebrowser.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
# It can retrieve and search through the file data, metadata, and logs.
55
# Data can be searched/sorted by DataObject type or by name, their properties can be examined, and
66
# they can be loaded individually or in groups.
7+
#
8+
# This file concludes with a few utility functions, either which are used by or which use the
9+
# FileBrowser class.
710

811
import h5py
912
import numpy as np
@@ -1083,11 +1086,13 @@ def get_py4DSTEM_topgroup(h5_file):
10831086

10841087
def check_version(current,minimum):
10851088
"Checks if current version is at least greater than required version."
1086-
test_sum = np.sum((np.subtract(current,minimum)>=0)*np.asarray((2,1)))
1087-
ref_sum = np.sum((np.asarray(minimum) >= 1)*np.asarray((2,1)))
1088-
if test_sum >= ref_sum:
1089-
#check to see if major and minor versions are >= in every category that exists in minimum required version
1089+
if current[0]>minimum[0]:
10901090
return True
1091+
elif current[0]==minimum[0]:
1092+
if current[1]>=minimum[1]:
1093+
return True
1094+
else:
1095+
return False
10911096
else:
10921097
return False
10931098

@@ -1131,4 +1136,18 @@ def show_log_item(index, log_item):
11311136
print("\t\t{}\t{}".format(key,value.decode('utf-8')))
11321137
else:
11331138
print("\t\t{}\t{}".format(key,value))
1134-
print("Version: \t{}\n".format(version))
1139+
print("Version: \t{}\n".format(version))
1140+
1141+
1142+
################## Quick file browsing ################
1143+
1144+
def show_dataobjects(filepath):
1145+
"""
1146+
Displays all DataObjects in the py4DSTEM HDF5 file at filepath.
1147+
"""
1148+
assert is_py4DSTEM_file(filepath), "filepath must point to a py4DSTEM HDF5 file."
1149+
browser = FileBrowser(filepath)
1150+
browser.show_dataobjects()
1151+
browser.close()
1152+
1153+

0 commit comments

Comments
 (0)