projects
/
hooke.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Store a copy of params in CurveCommand._add_to_command_stack.
[hooke.git]
/
hooke
/
plugin
/
curve.py
diff --git
a/hooke/plugin/curve.py
b/hooke/plugin/curve.py
index d73a67f90ce2267a58dd3d9ead05bb1aedccb689..b287ee4fa11bd5ad96f10de2269c6523ebd81bad 100644
(file)
--- a/
hooke/plugin/curve.py
+++ b/
hooke/plugin/curve.py
@@
-1,5
+1,5
@@
-# Copyright (C) 2008-2010 Alberto Gomez-
Kasai
-# Fab
iano's
Benedetti
+# Copyright (C) 2008-2010 Alberto Gomez-
Casado
+# Fab
rizio
Benedetti
# Massimo Sandal <devicerandom@gmail.com>
# W. Trevor King <wking@drexel.edu>
#
# Massimo Sandal <devicerandom@gmail.com>
# W. Trevor King <wking@drexel.edu>
#
@@
-41,15
+41,20
@@
from .playlist import current_playlist_callback
# Define common or complicated arguments
# Define common or complicated arguments
-def current_curve_callback(hooke, command, argument, value):
+def current_curve_callback(hooke, command, argument, value
, load=True
):
if value != None:
return value
playlist = current_playlist_callback(hooke, command, argument, value)
if value != None:
return value
playlist = current_playlist_callback(hooke, command, argument, value)
- curve = playlist.current()
+ curve = playlist.current(
load=load
)
if curve == None:
raise Failure('No curves in %s' % playlist)
return curve
if curve == None:
raise Failure('No curves in %s' % playlist)
return curve
+def unloaded_current_curve_callback(hooke, command, argument, value):
+ return current_curve_callback(
+ hooke=hooke, command=command, argument=argument, value=value,
+ load=False)
+
CurveArgument = Argument(
name='curve', type='curve', callback=current_curve_callback,
help="""
CurveArgument = Argument(
name='curve', type='curve', callback=current_curve_callback,
help="""
@@
-132,7
+137,7
@@
class CurveCommand (Command):
pass # no need to place duplicate calls on the stack.
else:
curve.command_stack.append(CommandMessage(
pass # no need to place duplicate calls on the stack.
else:
curve.command_stack.append(CommandMessage(
- self.name,
params
))
+ self.name,
dict(params)
))
class BlockCommand (CurveCommand):
class BlockCommand (CurveCommand):
@@
-285,8
+290,8
@@
class InfoCommand (CurveCommand):
Argument(name='all', type='bool', default=False, count=1,
help='Get all curve information.'),
]
Argument(name='all', type='bool', default=False, count=1,
help='Get all curve information.'),
]
- self.fields = ['name', 'path', 'experiment', 'driver', 'filetype',
'note',
- 'blocks', 'block sizes']
+ self.fields = ['name', 'path', 'experiment', 'driver', 'filetype',
+ '
note', 'command stack', '
blocks', 'block sizes']
for field in self.fields:
args.append(Argument(
name=field, type='bool', default=False, count=1,
for field in self.fields:
args.append(Argument(
name=field, type='bool', default=False, count=1,
@@
-300,7
+305,7
@@
class InfoCommand (CurveCommand):
fields = {}
for key in self.fields:
fields[key] = params[key]
fields = {}
for key in self.fields:
fields[key] = params[key]
- if reduce(lambda x,y: x
and
y, fields.values()) == False:
+ if reduce(lambda x,y: x
or
y, fields.values()) == False:
params['all'] = True # No specific fields set, default to 'all'
if params['all'] == True:
for key in self.fields:
params['all'] = True # No specific fields set, default to 'all'
if params['all'] == True:
for key in self.fields:
@@
-330,6
+335,9
@@
class InfoCommand (CurveCommand):
def _get_note(self, curve):
return curve.info.get('note', None)
def _get_note(self, curve):
return curve.info.get('note', None)
+ def _get_command_stack(self, curve):
+ return curve.command_stack
+
def _get_blocks(self, curve):
return len(curve.data)
def _get_blocks(self, curve):
return len(curve.data)
@@
-443,7
+451,7
@@
Name of the new column for storing the difference (without units, defaults to
def _run(self, hooke, inqueue, outqueue, params):
self._add_to_command_stack(params)
def _run(self, hooke, inqueue, outqueue, params):
self._add_to_command_stack(params)
- params = self._
_
setup_params(hooke=hooke, params=params)
+ params = self._setup_params(hooke=hooke, params=params)
data_A = self._get_column(hooke=hooke, params=params,
block_name='block A',
column_name='column A')
data_A = self._get_column(hooke=hooke, params=params,
block_name='block A',
column_name='column A')
@@
-456,7
+464,7
@@
Name of the new column for storing the difference (without units, defaults to
column_name='output column',
values=out)
column_name='output column',
values=out)
- def _
_
setup_params(self, hooke, params):
+ def _setup_params(self, hooke, params):
curve = self._curve(hooke, params)
if params['block A'] == None:
params['block A'] = curve.data[0].info['name']
curve = self._curve(hooke, params)
if params['block A'] == None:
params['block A'] = curve.data[0].info['name']
@@
-518,7
+526,7
@@
central differencing.
def _run(self, hooke, inqueue, outqueue, params):
self._add_to_command_stack(params)
def _run(self, hooke, inqueue, outqueue, params):
self._add_to_command_stack(params)
- params = self._
_
setup_params(hooke=hooke, params=params)
+ params = self._setup_params(hooke=hooke, params=params)
x_data = self._get_column(hooke=hooke, params=params,
column_name='x column')
f_data = self._get_column(hooke=hooke, params=params,
x_data = self._get_column(hooke=hooke, params=params,
column_name='x column')
f_data = self._get_column(hooke=hooke, params=params,
@@
-529,7
+537,7
@@
central differencing.
column_name='output column',
values=d)
column_name='output column',
values=d)
- def _
_
setup_params(self, hooke, params):
+ def _setup_params(self, hooke, params):
curve = self._curve(hooke, params)
x_name,x_unit = split_data_label(params['x column'])
f_name,f_unit = split_data_label(params['f column'])
curve = self._curve(hooke, params)
x_name,x_unit = split_data_label(params['x column'])
f_name,f_unit = split_data_label(params['f column'])
@@
-583,7
+591,7
@@
Otherwise, the chunks are end-to-end, and not overlapping.
def _run(self, hooke, inqueue, outqueue, params):
self._add_to_command_stack(params)
def _run(self, hooke, inqueue, outqueue, params):
self._add_to_command_stack(params)
- params = self._
_
setup_params(hooke=hooke, params=params)
+ params = self._setup_params(hooke=hooke, params=params)
data = self._get_column(hooke=hooke, params=params)
bounds = params['bounds']
if bounds != None:
data = self._get_column(hooke=hooke, params=params)
bounds = params['bounds']
if bounds != None:
@@
-607,7
+615,7
@@
Otherwise, the chunks are end-to-end, and not overlapping.
values=power)
outqueue.put(b)
values=power)
outqueue.put(b)
- def _
_
setup_params(self, hooke, params):
+ def _setup_params(self, hooke, params):
if params['output block'] in self._block_names(hooke, params):
raise Failure('output block %s already exists in %s.'
% (params['output block'],
if params['output block'] in self._block_names(hooke, params):
raise Failure('output block %s already exists in %s.'
% (params['output block'],
@@
-631,6
+639,11
@@
class ClearStackCommand (CurveCommand):
super(ClearStackCommand, self).__init__(
name='clear curve command stack',
help=self.__doc__, plugin=plugin)
super(ClearStackCommand, self).__init__(
name='clear curve command stack',
help=self.__doc__, plugin=plugin)
+ i,arg = [(i,arg) for i,arg in enumerate(self.arguments)
+ if arg.name == 'curve'][0]
+ arg = copy.copy(arg)
+ arg.callback = unloaded_current_curve_callback
+ self.arguments[i] = arg
def _run(self, hooke, inqueue, outqueue, params):
curve = self._curve(hooke, params)
def _run(self, hooke, inqueue, outqueue, params):
curve = self._curve(hooke, params)