Skip to content

Commit

Permalink
Add PyBool->bool mapping for PyAlg properties. Refs #4399.
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Mar 14, 2012
1 parent 42fd048 commit 227a5e5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace Mantid
// Map the Python types to the best match in C++
REGISTER_MAPPING(PyFloat_Type, double);
REGISTER_MAPPING(PyInt_Type, long);
REGISTER_MAPPING(PyBool_Type, bool);
REGISTER_MAPPING(PyString_Type, std::string);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@
from mantid import PythonAlgorithm, Direction
from mantid import BoundedValidator, FileProperty, FileAction


class BasicPropsAlg(PythonAlgorithm):

def PyInit(self):
self.declareProperty('SimpleInput', 1)
self.declareProperty('SimpleOutput', 1.0, Direction.Output)
self.declareProperty('InputString', "", Direction.Input)

def PyExec(self):
pass


# ======================================================================

class PythonAlgorithmPropertiesTest(unittest.TestCase):
Expand All @@ -32,6 +22,7 @@ class BasicPropsAlg(PythonAlgorithm):
_testdocstring = "This is a doc string"
def PyInit(self):
self.declareProperty('SimpleInput', 1)
self.declareProperty('Switch', True)
self.declareProperty('SimpleOutput', 1.0, Direction.Output)
self.declareProperty('InputString', "", Direction.Input)
self.declareProperty('PropWithDocDefaultDir', 1, self._testdocstring)
Expand All @@ -46,11 +37,14 @@ def PyExec(self):
self.assertEquals(0, len(props))
alg.initialize()
props = alg.getProperties()
self.assertEquals(5, len(props))
self.assertEquals(6, len(props))

input = alg.getProperty("SimpleInput")
self.assertEquals(input.direction, Direction.Input)
self.assertEquals(input.value, 1)
switch = alg.getProperty("Switch")
self.assertEquals(switch.direction, Direction.Input)
self.assertEquals(switch.value, True)
output = alg.getProperty("SimpleOutput")
self.assertEquals(output.direction, Direction.Output)
self.assertEquals(output.value, 1.0)
Expand Down

0 comments on commit 227a5e5

Please sign in to comment.