From a9525fab21ee01cd59e283a699aa7fc981f680c0 Mon Sep 17 00:00:00 2001 From: Gard Spreemann Date: Wed, 4 Apr 2018 16:10:08 +0200 Subject: Support for reading and writing compressed dipha files. --- phstuff/diphawrapper.py | 19 ++++++++++--------- phstuff/misc.py | 7 +++++++ setup.py | 2 +- 3 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 phstuff/misc.py diff --git a/phstuff/diphawrapper.py b/phstuff/diphawrapper.py index f0a61de..930fbe2 100644 --- a/phstuff/diphawrapper.py +++ b/phstuff/diphawrapper.py @@ -9,6 +9,7 @@ import subprocess import phstuff.barcode as bc import phstuff.simplicial as simpl +import phstuff.misc as misc """Handle marshalling data into and out of DIPHA's formats, and optionally manage running the DIPHA executable. @@ -57,7 +58,7 @@ def save_weight_matrix(fname, weights): if weights.shape[0] != weights.shape[1]: raise ValueError("Matrix is not square.") - with open(fname, "wb") as f: + with misc.gz_wrapper(fname, "wb") as f: f.write(struct.pack("