@@ -204,7 +204,8 @@ def __getitem__(self, key):
204
204
if key in self .data .dtype .names :
205
205
return self .data [key ]
206
206
if key in self .head .dtype .names :
207
- return self .head [key ][0 ]
207
+ return np .atleast_1d (self .head [key ])[0 ]
208
+
208
209
209
210
try :
210
211
return self .__dict__ [key ]
@@ -254,26 +255,35 @@ def _loadPickle(self, pickname, filename):
254
255
# Get checksum
255
256
filehash = _hash (filename )
256
257
try :
257
- pickhash = pickle .load (f )
258
- except :
258
+ version = pickle .load (f )
259
+ except Exception :
259
260
raise ValueError ("Pickle file corrupted please delete it and try again" )
260
- if len (str (pickhash )) == len (str (_PICKLE_VERSION )):
261
- if int (pickhash ) != int (_PICKLE_VERSION ):
262
- # Not a hash but a version number/ or wrong version number:
263
- return False
264
261
265
- try :
262
+ # For mesaplot 1.* this is a hash, while 2.* is a version number
263
+ if len (str (version )) > 12 :
264
+ # Version 1.0 hash
265
+ pickhash = version
266
+ else :
267
+ if int (version ) != int (_PICKLE_VERSION ):
268
+ raise ValueError ("Pickle file not recongised please delete it and try again" )
269
+
266
270
pickhash = pickle .load (f )
267
- except TypeError :
268
- return False
269
271
270
272
if (
271
273
os .path .exists (filename ) and pickhash == filehash
272
274
) or not os .path .exists (filename ):
273
275
# Data has not changed
274
276
# Get Data
275
- self .data = pickle .load (f )
276
- self .head = pickle .load (f )
277
+ data = pickle .load (f )
278
+
279
+ try :
280
+ head = pickle .load (f )
281
+ self .head = head
282
+ self .data = data
283
+ except EOFError : # Handle 1.* verisons of pickle files
284
+ self .data = data .data
285
+ self .head = data .head
286
+
277
287
self ._loaded = True
278
288
return True
279
289
return False
0 commit comments