From 50f97b9c1817e0cd6bd363a32c3fcbcca5be3ca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E4=B9=A6=E8=BD=A9?= Date: Thu, 16 Jul 2020 18:38:44 +0800 Subject: [PATCH] fix compatibility problem when read pickle file in example.py --- traj_dist/example.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/traj_dist/example.py b/traj_dist/example.py index be7479c..4bcbe3c 100644 --- a/traj_dist/example.py +++ b/traj_dist/example.py @@ -2,7 +2,12 @@ import traj_dist.distance as tdist import pickle -traj_list = pickle.load(open("/Users/bguillouet/These/trajectory_distance/data/benchmark_trajectories.pkl", "rb"))[:10] +#because pickle compatibility problem between python 3.6 and python 2.7,we should use this way to open old pkl file +#refer https://stackoverflow.com/questions/11305790/pickle-incompatibility-of-numpy-arrays-between-python-2-and-3?newreg=8c4b4c32700e4119a3735ecd1f0bb5ca +with open('/Users/bguillouet/These/trajectory_distance/data/benchmark_trajectories.pkl', 'rb') as f: + u = pickle._Unpickler(f) + u.encoding = 'latin1' + traj_list = u.load()[:10] traj_A = traj_list[0] traj_B = traj_list[1]