Mantid
Loading...
Searching...
No Matches
Classes | Macros | Functions
ITableWorkspace.cpp File Reference
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Column.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/WorkspaceProperty.h"
#include "MantidKernel/V3D.h"
#include "MantidKernel/WarningSuppressions.h"
#include "MantidPythonInterface/api/RegisterWorkspacePtrToPython.h"
#include "MantidPythonInterface/core/Converters/CloneToNDArray.h"
#include "MantidPythonInterface/core/Converters/NDArrayToVector.h"
#include "MantidPythonInterface/core/Converters/PySequenceToVector.h"
#include "MantidPythonInterface/core/GetPointer.h"
#include "MantidPythonInterface/core/NDArray.h"
#include "MantidPythonInterface/core/Policies/VectorToNumpy.h"
#include "MantidPythonInterface/core/VersionCompat.h"
#include <boost/preprocessor/list/for_each.hpp>
#include <boost/preprocessor/tuple/to_list.hpp>
#include <boost/python/class.hpp>
#include <boost/python/converter/builtin_converters.hpp>
#include <boost/python/dict.hpp>
#include <boost/python/list.hpp>
#include <boost/python/make_constructor.hpp>
#include <boost/python/overloads.hpp>
#include <cstring>
#include <vector>
#include <numpy/arrayobject.h>

Go to the source code of this file.

Classes

class  ITableWorkspacePickleSuite
 

Macros

#define ARRAY_TYPES   BOOST_PP_TUPLE_TO_LIST(2, (std::vector<int>, std::vector<double>))
 
#define BUILTIN_TYPES   BOOST_PP_TUPLE_TO_LIST(8, (double, std::string, int, size_t, uint32_t, int64_t, float, uint64_t))
 Boost macro for "looping" over builtin types. More...
 
#define GET_ARRAY(R, _, T)
 
#define GET_BUILTIN(R, _, T)
 
#define GET_USER(R, _, T)
 
#define IS_ARRAY_INTEGER(obj)   (PyLong_Check(obj) || PyArray_IsScalar((obj), Integer))
 
#define NO_IMPORT_ARRAY
 
#define PY_ARRAY_UNIQUE_SYMBOL   API_ARRAY_API
 
#define SET_CELL(R, _, T)
 
#define SET_VECTOR_CELL(R, _, T)
 
#define STR_CHECK   PyUnicode_Check
 
#define TO_LONG   PyLong_AsLong
 
#define USER_TYPES   BOOST_PP_TUPLE_TO_LIST(1, (Mantid::Kernel::V3D))
 

Functions

void export_ITableWorkspace ()
 
dict toDict (const ITableWorkspace &self)
 Get the contents of the workspace as a python dictionary. More...
 

Macro Definition Documentation

◆ ARRAY_TYPES

#define ARRAY_TYPES   BOOST_PP_TUPLE_TO_LIST(2, (std::vector<int>, std::vector<double>))

Definition at line 65 of file ITableWorkspace.cpp.

◆ BUILTIN_TYPES

#define BUILTIN_TYPES   BOOST_PP_TUPLE_TO_LIST(8, (double, std::string, int, size_t, uint32_t, int64_t, float, uint64_t))

Boost macro for "looping" over builtin types.

Definition at line 63 of file ITableWorkspace.cpp.

◆ GET_ARRAY

#define GET_ARRAY (   R,
  _,
 
)
Value:
else if (typeID.hash_code() == typeid(T).hash_code()) { \
result = Converters::Clone::apply<T::value_type>::create1D(column->cell<T>(row)); \
}

◆ GET_BUILTIN

#define GET_BUILTIN (   R,
  _,
 
)
Value:
else if (typeID.hash_code() == typeid(T).hash_code()) { \
result = to_python_value<const T &>()(column->cell<T>(row)); \
}

◆ GET_USER

#define GET_USER (   R,
  _,
 
)
Value:
else if (typeID.hash_code() == typeid(T).hash_code()) { \
const converter::registration *entry = converter::registry::query(typeid(T)); \
if (!entry) \
throw std::invalid_argument("Cannot find converter from C++ type."); \
result = entry->to_python((const void *)&column->cell<T>(row)); \
}

◆ IS_ARRAY_INTEGER

#define IS_ARRAY_INTEGER (   obj)    (PyLong_Check(obj) || PyArray_IsScalar((obj), Integer))

Definition at line 57 of file ITableWorkspace.cpp.

◆ NO_IMPORT_ARRAY

#define NO_IMPORT_ARRAY

Definition at line 39 of file ITableWorkspace.cpp.

◆ PY_ARRAY_UNIQUE_SYMBOL

#define PY_ARRAY_UNIQUE_SYMBOL   API_ARRAY_API

Definition at line 38 of file ITableWorkspace.cpp.

◆ SET_CELL

#define SET_CELL (   R,
  _,
 
)
Value:
else if (typeID.hash_code() == typeid(T).hash_code()) { \
column->cell<T>(row) = extract<T>(value)(); \
}
double value
The value of the point.
Definition: FitMW.cpp:51

◆ SET_VECTOR_CELL

#define SET_VECTOR_CELL (   R,
  _,
 
)
Value:
else if (typeID.hash_code() == typeid(T).hash_code()) { \
if (!NDArray::check(value)) { \
} else { \
} \
}
static bool check(const boost::python::object &obj)
Check if a python object points to an array type object.
Definition: NDArray.cpp:49
Converter taking an input numpy array and converting it to a std::vector.
Converts a Python sequence type to a C++ std::vector, where the element type is defined by the templa...

◆ STR_CHECK

#define STR_CHECK   PyUnicode_Check

Definition at line 55 of file ITableWorkspace.cpp.

◆ TO_LONG

#define TO_LONG   PyLong_AsLong

Definition at line 54 of file ITableWorkspace.cpp.

◆ USER_TYPES

#define USER_TYPES   BOOST_PP_TUPLE_TO_LIST(1, (Mantid::Kernel::V3D))

Definition at line 64 of file ITableWorkspace.cpp.

Function Documentation

◆ export_ITableWorkspace()

void export_ITableWorkspace ( )

◆ toDict()

dict toDict ( const ITableWorkspace self)

Get the contents of the workspace as a python dictionary.

Parameters
selfA reference to the TableWorkspace python object that we were called on
Returns
a boost python dictionary object with keys that are column names and values which are lists of the column values.

Definition at line 566 of file ITableWorkspace.cpp.

References Mantid::API::ITableWorkspace::getColumnNames().

Referenced by export_ITableWorkspace(), and ITableWorkspacePickleSuite::getstate().