Commit 18558bce authored by Rob Applin's avatar Rob Applin
Browse files

Refs #0. Add deprecation warning.

parent c480d6be
......@@ -136,7 +136,7 @@ public:
/// spectra.
virtual std::size_t blocksize() const = 0;
/// Returns the number of bins for a given histogram index.
virtual std::size_t getNumberBins(const std::size_t &index = 0) const = 0;
virtual std::size_t getNumberBins(const std::size_t &index) const = 0;
/// Returns the maximum number of bins in a workspace (works on ragged data).
virtual std::size_t getMaxNumberBins() const = 0;
/// Returns the number of histograms in the workspace
......
......@@ -69,7 +69,7 @@ public:
// Get the blocksize, aka the number of bins in the histogram
std::size_t blocksize() const override;
/// Returns the number of bins for a given histogram index.
std::size_t getNumberBins(const std::size_t &index = 0) const override;
std::size_t getNumberBins(const std::size_t &index) const override;
/// Returns the maximum number of bins in a workspace (works on ragged data).
std::size_t getMaxNumberBins() const override;
......
......@@ -56,7 +56,7 @@ public:
std::size_t blocksize() const override;
/// Returns the number of bins for a given histogram index.
std::size_t getNumberBins(const std::size_t &index = 0) const override;
std::size_t getNumberBins(const std::size_t &index) const override;
/// Returns the maximum number of bins in a workspace (works on ragged data).
std::size_t getMaxNumberBins() const override;
......
......@@ -48,7 +48,7 @@ public:
/// Returns the size of each block of data returned by the dataX accessors
std::size_t blocksize() const override { return 1; }
/// Returns the number of bins for a given histogram index.
std::size_t getNumberBins(const std::size_t &index = 0) const override {
std::size_t getNumberBins(const std::size_t &index) const override {
UNUSED_ARG(index);
return 1;
}
......
......@@ -163,14 +163,6 @@ public:
TS_ASSERT_THROWS(ew->blocksize(), const std::logic_error &);
}
void
test_that_getNumberBins_returns_the_number_of_bins_in_the_first_histogram_by_default() {
ew = createEventWorkspace(true, false);
ew->getSpectrum(0).setHistogram(BinEdges({0., 10., 20.}));
TS_ASSERT_EQUALS(ew->getNumberBins(), 2);
}
void
test_that_getNumberBins_returns_the_correct_number_of_bins_for_different_histograms_in_a_ragged_EventWorkspace() {
ew = createEventWorkspace(true, false);
......
......@@ -94,14 +94,6 @@ public:
TS_ASSERT_THROWS(cloned->blocksize(), const std::logic_error &);
}
void
test_that_getNumberBins_returns_the_number_of_bins_in_the_first_histogram_by_default() {
Workspace2D_sptr cloned(ws->clone());
cloned->setHistogram(0, Points(0), Counts(0));
TS_ASSERT_EQUALS(cloned->getNumberBins(), 0);
}
void
test_that_getNumberBins_returns_the_correct_number_of_bins_for_different_histograms_in_a_ragged_Workspace2D() {
Workspace2D_sptr cloned(ws->clone());
......
......@@ -109,7 +109,6 @@ public:
void
test_that_getNumberBins_and_getMaxNumberBins_returns_one_for_a_WorkspaceSingleValue() {
WorkspaceSingleValue ws;
TS_ASSERT_EQUALS(ws.getNumberBins(), 1);
TS_ASSERT_EQUALS(ws.getNumberBins(0), 1);
TS_ASSERT_EQUALS(ws.getMaxNumberBins(), 1);
}
......
......@@ -64,9 +64,6 @@ GNU_DIAG_OFF("unused-local-typedef")
// Ignore -Wconversion warnings coming from boost::python
// Seen with GCC 7.1.1 and Boost 1.63.0
GNU_DIAG_OFF("conversion")
// Overloads for getNumberBins function which has 1 optional argument
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_getNumberBinsOverloads,
MatrixWorkspace::getNumberBins, 0, 1)
// Overloads for yIndexOfX function which has 2 optional argument
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(MatrixWorkspace_yIndexOfXOverloads,
MatrixWorkspace::yIndexOfX, 1, 3)
......@@ -199,6 +196,18 @@ Mantid::API::Run &getSampleDetailsDeprecated(MatrixWorkspace &self) {
return self.mutableRun();
}
/**
* 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()
*/
std::size_t getNumberBinsDeprecated(MatrixWorkspace &self) {
PyErr_Warn(PyExc_DeprecationWarning,
"``getNumberBins`` is deprecated, use ``blocksize`` instead.");
return self.blocksize();
}
/**
* Adds a deprecation warning to the binIndexOf call to warn about using
* yIndexOfX instead
......@@ -342,10 +351,12 @@ void export_MatrixWorkspace() {
.def("blocksize", &MatrixWorkspace::blocksize, arg("self"),
"Returns size of the Y data array")
.def("getNumberBins", &MatrixWorkspace::getNumberBins,
MatrixWorkspace_getNumberBinsOverloads(
(arg("self"), arg("index")), "Returns the number of bins for a "
"given histogram index. Default is "
"the zeroth histogram index."))
(arg("self"), arg("index")),
"Returns the number of bins for a given histogram index.")
.def("getNumberBins", &getNumberBinsDeprecated, arg("self"),
"Returns size of the Y data array (deprecated, use "
":class:`~mantid.api.MatrixWorkspace.blocksize` "
"instead)")
.def("getMaxNumberBins", &MatrixWorkspace::getMaxNumberBins, arg("self"),
"Returns the maximum number of bins in a workspace (works on ragged "
"data).")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment