Skip to content
Snippets Groups Projects
Commit cde39b46 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

Renamed RETURN to LOAD

parent 282ab2d6
No related branches found
No related tags found
No related merge requests found
...@@ -12,7 +12,7 @@ from .wrapperutils import (applyArgStyle, # noqa ...@@ -12,7 +12,7 @@ from .wrapperutils import (applyArgStyle, # noqa
required, required,
fileOrImage, fileOrImage,
fileOrArray, fileOrArray,
RETURN, LOAD,
SHOW_IF_TRUE, SHOW_IF_TRUE,
HIDE_IF_TRUE) HIDE_IF_TRUE)
from .bet import (bet,) # noqa from .bet import (bet,) # noqa
......
...@@ -220,7 +220,7 @@ def argsToKwargs(func, args): ...@@ -220,7 +220,7 @@ def argsToKwargs(func, args):
return kwargs return kwargs
RETURN = object() LOAD = object()
"""Constant used by the :class:`_FileOrThing` class to indicate that an output """Constant used by the :class:`_FileOrThing` class to indicate that an output
file should be loaded into memory and returned as a Python object. file should be loaded into memory and returned as a Python object.
""" """
...@@ -252,11 +252,11 @@ class _FileOrThing(object): ...@@ -252,11 +252,11 @@ class _FileOrThing(object):
**Outputs** **Outputs**
If an argument is given the special :data:`RETURN` value, it is assumed If an argument is given the special :data:`LOAD` value, it is assumed
to be an output argument. In this case, it is replaced with a temporary to be an output argument. In this case, it is replaced with a temporary
file name then, after the function has completed, that file is loaded file name then, after the function has completed, that file is loaded
into memory, and the value returned (along with the function's output, into memory, and the value returned (along with the function's output,
and any other arguments with a value of ``RETURN``). and any other arguments with a value of ``LOAD``).
**Return value** **Return value**
...@@ -265,9 +265,8 @@ class _FileOrThing(object): ...@@ -265,9 +265,8 @@ class _FileOrThing(object):
Functions decorated with a ``_FileOrThing`` decorator will always return a Functions decorated with a ``_FileOrThing`` decorator will always return a
tuple, where the first element is the function's actual return value. The tuple, where the first element is the function's actual return value. The
remainder of the tuple will contain any arguments that were given the remainder of the tuple will contain any arguments that were given the
special ``RETURN`` value. ``None`` is returned for any ``RETURN`` special ``LOAD`` value. ``None`` is returned for any ``LOAD`` arguments
arguments corresponded to output files that were not generated by the corresponded to output files that were not generated by the function.
function.
**Example** **Example**
...@@ -304,12 +303,12 @@ class _FileOrThing(object): ...@@ -304,12 +303,12 @@ class _FileOrThing(object):
# The output is returned as a numpy # The output is returned as a numpy
# array (in a tuple with the concat # array (in a tuple with the concat
# function's return value) # function's return value)
atoc = concat('atob.txt', 'btoc.txt', RETURN)[1] atoc = concat('atob.txt', 'btoc.txt', LOAD)[1]
# The inputs are saved to temporary # The inputs are saved to temporary
# files, and those file names are # files, and those file names are
# passed to the concat function. # passed to the concat function.
atoc = concat(np.diag([2, 2, 2, 0]), np.diag([3, 3, 3, 3]), RETURN)[1] atoc = concat(np.diag([2, 2, 2, 0]), np.diag([3, 3, 3, 3]), LOAD)[1]
""" """
...@@ -318,7 +317,7 @@ class _FileOrThing(object): ...@@ -318,7 +317,7 @@ class _FileOrThing(object):
:arg prepareThing: Function which :arg prepareThing: Function which
:arg loadThing: Function which is called for arguments that :arg loadThing: Function which is called for arguments that
were set to :data:`RETURN`. were set to :data:`LOAD`.
:arg things: :arg things:
""" """
...@@ -343,7 +342,7 @@ class _FileOrThing(object): ...@@ -343,7 +342,7 @@ class _FileOrThing(object):
def __wrapper(self, func, isFileOrThing, *args, **kwargs): def __wrapper(self, func, isFileOrThing, *args, **kwargs):
"""Function which wraps ``func``, ensuring that any arguments of """Function which wraps ``func``, ensuring that any arguments of
type ``Thing`` are saved to temporary files, and any arguments type ``Thing`` are saved to temporary files, and any arguments
with the value :data:`RETURN` are loaded and returned. with the value :data:`LOAD` are loaded and returned.
:arg func: The func being wrapped. :arg func: The func being wrapped.
...@@ -368,9 +367,9 @@ class _FileOrThing(object): ...@@ -368,9 +367,9 @@ class _FileOrThing(object):
result = func(**kwargs) result = func(**kwargs)
# Load the output things that # Load the output things that
# were specified as RETURN
outthings = [] outthings = []
for of in outfiles: for of in outfiles:
# were specified as LOAD
# output file didn't get created # output file didn't get created
if not op.exists(of): if not op.exists(of):
...@@ -456,7 +455,7 @@ def fileOrImage(*imgargs): ...@@ -456,7 +455,7 @@ def fileOrImage(*imgargs):
# caller has requested that it be # caller has requested that it be
# returned from the function call # returned from the function call
# as an in-memory image. # as an in-memory image.
elif val == RETURN: elif val == LOAD:
newval = op.join(workdir, '{}.nii.gz'.format(name)) newval = op.join(workdir, '{}.nii.gz'.format(name))
outfile = newval outfile = newval
...@@ -498,7 +497,7 @@ def fileOrArray(*arrargs): ...@@ -498,7 +497,7 @@ def fileOrArray(*arrargs):
# This is an output, and the caller has # This is an output, and the caller has
# requested that it be returned from the # requested that it be returned from the
# function call as an in-memory array. # function call as an in-memory array.
elif val == RETURN: elif val == LOAD:
newval = op.join(workdir, '{}.txt'.format(name)) newval = op.join(workdir, '{}.txt'.format(name))
outfile = newval outfile = newval
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment