Skip to content

Commit 67c5622

Browse files
committed
Start switching np.load(...,allow_pickle=True) as needed
Even though these 2x calls load .npz files, they contain NumPy object arrays of ShotList class objects that are implicitly serialized by Pickle via np.savez() calls. Also, fix bug with sorted(ShotList) being converted to a List instead of a ShotList.
1 parent cc71f3e commit 67c5622

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

plasma/preprocessor/preprocess.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def get_shot_list_path(self):
138138

139139
def load_shotlists(self):
140140
path = self.get_shot_list_path()
141-
data = np.load(path, encoding="latin1", allow_pickle=False)
141+
data = np.load(path, encoding="latin1", allow_pickle=True)
142142
shot_list_train = data['shot_list_train'][()]
143143
shot_list_validate = data['shot_list_validate'][()]
144144
shot_list_test = data['shot_list_test'][()]
@@ -239,7 +239,8 @@ def guarantee_preprocessed(conf):
239239
else:
240240
print("preprocessing all shots", end='')
241241
pp.clean_shot_lists()
242-
shot_list = sorted(pp.preprocess_all())
242+
shot_list = pp.preprocess_all()
243+
shot_list.sort()
243244
shot_list_train, shot_list_test = shot_list.split_train_test(conf)
244245
# num_shots = len(shot_list_train) + len(shot_list_test)
245246
validation_frac = conf['training']['validation_frac']

plasma/primitives/shots.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def get_save_path(self, prepath):
498498
def restore(self, prepath, light=False):
499499
assert self.previously_saved(prepath), 'shot was never saved'
500500
save_path = self.get_save_path(prepath)
501-
dat = np.load(save_path, encoding="latin1", allow_pickle=False)
501+
dat = np.load(save_path, encoding="latin1", allow_pickle=True)
502502

503503
self.valid = dat['valid'][()]
504504
self.is_disruptive = dat['is_disruptive'][()]

0 commit comments

Comments
 (0)