Skip to content

Commit

Permalink
Add deprecated functions to new API to aid in transition. Refs #6639
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Mar 11, 2013
1 parent 20e3ba9 commit cc4cbb5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,28 @@ namespace
setSpectrumFromPyObject(self, &MatrixWorkspace::dataE, wsIndex, values);
}

/**
* Adds a deprecation warning to the getNumberBins call to warn about using blocksize instead
* @param self A reference to the calling object
* @returns The blocksize()
*/
size_t getNumberBinsDeprecated(MatrixWorkspace & self)
{
PyErr_Warn(PyExc_DeprecationWarning, "'getNumberBins' is deprecated, use 'blocksize' instead.");
return self.blocksize();
}

/**
* Adds a deprecation warning to the getSampleDetails call to warn about using getRun instead
* @param self A reference to the calling object
* @returns getRun()
*/
Mantid::API::Run & getSampleDetailsDeprecated(MatrixWorkspace & self)
{
PyErr_Warn(PyExc_DeprecationWarning, "'getSampleDetails' is deprecated, use 'getRun' instead.");
return self.mutableRun();
}

}

void export_MatrixWorkspace()
Expand Down Expand Up @@ -130,6 +152,10 @@ void export_MatrixWorkspace()
.def("YUnit", &MatrixWorkspace::YUnit, "Returns the current Y unit for the data (Y axis) in the workspace")
.def("YUnitLabel", &MatrixWorkspace::YUnitLabel, "Returns the caption for the Y axis")

// Deprecated
.def("getNumberBins", &getNumberBinsDeprecated, "Returns size of the Y data array (deprecated, use blocksize instead)")
.def("getSampleDetails", &getSampleDetailsDeprecated, return_internal_reference<>(), "Return the Run object for this workspace (deprecated, use getRun instead)")

//--------------------------------------- Setters -------------------------------------------------------------------------------
.def("setYUnitLabel", &MatrixWorkspace::setYUnitLabel, "Sets a new caption for the data (Y axis) in the workspace")
.def("setYUnit", &MatrixWorkspace::setYUnit, "Sets a new unit for the data (Y axis) in the workspace")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,25 @@ using Mantid::Kernel::Unit;
using Mantid::Kernel::Unit_sptr;
using namespace boost::python;

namespace
{
/**
* Returns the full name of the unit & raises a deprecation warning
* @param self A reference to calling object
*/
const std::string deprecatedName(Unit & self)
{
PyErr_Warn(PyExc_DeprecationWarning, "'name' is deprecated, use 'caption' instead.");
return self.caption();
}
}

void export_Unit()
{
REGISTER_SHARED_PTR_TO_PYTHON(Unit);

class_<Unit,boost::noncopyable>("Unit", no_init)
.def("name", &deprecatedName, "Return the full name of the unit (deprecated, use caption)")
.def("caption", &Unit::caption, "Return the full name of the unit")
.def("label", &Unit::label, "Returns a label to be printed on the axis")
.def("unitID", &Unit::unitID, "Returns the string ID of the unit. This may/may not match its name")
Expand Down

0 comments on commit cc4cbb5

Please sign in to comment.