Skip to content

Commit

Permalink
Fix pickles to use binary files
Browse files Browse the repository at this point in the history
This is actually how pickling is *supposed* to be used and enables
sharing of pickled objects between Python 2 and 3.
  • Loading branch information
jni committed Jan 28, 2015
1 parent 5a1456c commit ce81257
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
rundir = os.path.dirname(__file__)
sys.path.append(rundir)


PYTHON = sys.version_info[0]


from gala import agglo, features


Expand Down Expand Up @@ -66,7 +70,11 @@ def run_matched(f, fn, c=1,
p = probs1 if c == 1 else probs2
g = agglo.Rag(wss1, p, feature_manager=f)
o = list_of_feature_arrays(g, f, edges, merges)
r = pck.load(open(fn, 'r'))
with open(fn, 'rb') as fin:
if PYTHON == 2:
r = pck.load(fin)
else:
r = pck.load(fin, encoding='bytes')
assert_equal_lists_or_arrays(o, r)


Expand Down
Binary file modified tests/toy-data/test-04-composite-2channel-12-13.pck
Binary file not shown.
Binary file modified tests/toy-data/test-04-histogram-1channel-12-13.pck
Binary file not shown.
Binary file modified tests/toy-data/test-04-histogram-2channel-12-13.pck
Binary file not shown.
Binary file modified tests/toy-data/test-04-moments-2channel-12-13.pck
Binary file not shown.
Binary file modified tests/toy-data/test-04-squiggle-1channel-12-13.pck
Binary file not shown.

0 comments on commit ce81257

Please sign in to comment.