Skip to content

Commit

Permalink
refs #4444. Fixes python docs for Algorithm Dialog usage
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenArnold committed Jan 11, 2012
1 parent 0aa5715 commit 2ffbacd
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace
/**
* Returns a list of input property names that is ordered such that the
* mandatory properties are first followed by the optional ones. The list
* also includes InOut properties.
* excludes output properties.
* @param self :: A pointer to the python object wrapping and Algorithm.
* @return A Python list of strings
*/
Expand All @@ -69,6 +69,28 @@ namespace
return names;
}

/**
* Returns a list of input property names that is ordered such that the
* mandatory properties are first followed by the optional ones. The list
* also includes InOut properties.
* @param self :: A pointer to the python object wrapping and Algorithm.
* @return A Python list of strings
*/
PyObject * getAlgorithmPropertiesOrdered(IAlgorithm & self)
{
PropVector properties(self.getProperties()); // Makes a copy so that it can be sorted
std::sort(properties.begin(), properties.end(), MandatoryFirst());
PropVector::const_iterator iend = properties.end();
// Build a python list
PyObject *names = PyList_New(0);
for (PropVector::const_iterator itr = properties.begin(); itr != iend; ++itr)
{
Property *p = *itr;
PyList_Append(names, PyString_FromString(p->name().c_str()));
}
return names;
}

/**
* Returns a list of output property names in the order they were declared in
* @param self :: A pointer to the python object wrapping and Algorithm.
Expand Down Expand Up @@ -159,6 +181,8 @@ void export_algorithm()
.def("docString", &createDocString, "Returns a doc string for the algorithm")
.def("mandatoryProperties",&getInputPropertiesWithMandatoryFirst, "Returns a list of input and in/out property names that is ordered "
"such that the mandatory properties are first followed by the optional ones.")
.def("orderedProperties", &getAlgorithmPropertiesOrdered, "Return a list of input, in/out and output properties "
"such that the mandatory properties are first followed by the optional ones.")
.def("outputProperties",&getOutputProperties, "Returns a list of the output properties on the algorithm")
.def("isInitialized", &IAlgorithm::isInitialized, "Returns True if the algorithm is initialized, False otherwise")
.def("isExecuted", &IAlgorithm::isExecuted, "Returns true if the algorithm has been executed successfully, false otherwise")
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/PythonInterface/mantid/simpleapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def algorithm_wrapper(*args, **kwargs):
# Dark magic to get the correct function signature
#_algm_object = mtd.createUnmanagedAlgorithm(algorithm, version)
arg_list = []
for p in _algm_object.mandatoryProperties():
for p in _algm_object.orderedProperties():
arg_list.append("%s=None" % p)
arg_str = ','.join(arg_list)
signature = "\b%s" % arg_str
Expand Down

0 comments on commit 2ffbacd

Please sign in to comment.