From ecf758558269028c28ef18bbe6a9ab7654890346 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Wed, 19 May 2010 06:16:27 -0400 Subject: [PATCH] Use numpy.savetxt (handles multiple columns) rather than ndarray.tofile --- hooke/plugin/curve.py | 8 ++++---- hooke/plugin/cut.py | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/hooke/plugin/curve.py b/hooke/plugin/curve.py index b93ccbc..b63f250 100644 --- a/hooke/plugin/curve.py +++ b/hooke/plugin/curve.py @@ -24,6 +24,8 @@ associated :class:`hooke.command.Command`\s for handling :mod:`hooke.curve` classes. """ +import numpy + from ..command import Command, Argument, Failure from ..curve import Data from ..plugin import Builtin @@ -143,10 +145,8 @@ File name for the output data. Defaults to 'curve.dat' help=self.__doc__, plugin=plugin) def _run(self, hooke, inqueue, outqueue, params): - data = params['curve'].data[params['block']] - f = open(params['output'], 'w') - data.tofile(f, sep='\t') - f.close() + data = params['curve'].data[int(params['block'])] # HACK, int() should be handled by ui + numpy.savetxt(params['output'], data, delimiter='\t') class DifferenceCommand (Command): """Calculate the derivative (actually, the discrete differentiation) diff --git a/hooke/plugin/cut.py b/hooke/plugin/cut.py index 2771ef5..18e30b9 100644 --- a/hooke/plugin/cut.py +++ b/hooke/plugin/cut.py @@ -22,6 +22,8 @@ :class:`CutCommand`. """ +import numpy + from ..command import Command, Argument, Failure from ..plugin import Plugin @@ -90,6 +92,4 @@ File name for the output data. cut_data = data[i_min:i_max+1,:] # slice rows from row-major data # +1 to include data[i_max] row - f = open(params['output'], 'w') - cut_data.tofile(f, sep='\t') - f.close() + numpy.savetxt(params['output'], cut_data, delimiter='\t') -- 2.26.2