Skip to content
Snippets Groups Projects
Commit 02ab6b37 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #7371. Fix cell setting and fetching and test.

parent 46691031
No related merge requests found
......@@ -30,7 +30,7 @@ namespace
/// Boost macro for "looping" over builtin types
#define BUILTIN_TYPES \
BOOST_PP_TUPLE_TO_LIST( \
6, (double, std::string, int, int64_t, bool, float) \
6, (double, std::string, int, int64_t, float) \
)
#define USER_TYPES \
BOOST_PP_TUPLE_TO_LIST( \
......@@ -46,6 +46,12 @@ namespace
*/
PyObject *getValue(Mantid::API::Column_const_sptr column, const std::type_info & typeID, const int row)
{
if(typeID == typeid(Mantid::API::Boolean))
{
bool res = column->cell<Mantid::API::Boolean>(row);
return to_python_value<const bool&>()(res);
}
#define GET_BUILTIN(R, _, T) \
else if(typeID == typeid(T)) \
{\
......@@ -80,6 +86,12 @@ namespace
*/
void setValue(const Column_sptr column, const int row, const bpl::object & value)
{
if(column->get_type_info() == typeid(Mantid::API::Boolean))
{
column->cell<Mantid::API::Boolean>(row) = bpl::extract<bool>(value)();
return;
}
#define SET_CELL(R, _, T) \
else if(typeID == typeid(T)) \
{\
......
......@@ -99,6 +99,15 @@ class ITableWorkspaceTest(unittest.TestCase):
self.assertEquals(insertedrow, nextrow)
insertedrow = table.row(0)
self.assertEquals(insertedrow, nextrow)
def test_set_and_extract_boolean_columns(self):
table = WorkspaceFactory.createTable()
table.addColumn(type='bool', name='yes_no')
table.addRow([True])
table.addRow([False])
self.assertTrue(table.cell(0, 0))
self.assertFalse(table.cell(1, 0))
if __name__ == '__main__':
unittest.main()
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