From d1cf4092bc1eac75061e437efe03c56141d4d152 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 9 Nov 2021 16:57:25 +0100
Subject: [PATCH 1/3] typo in comment

---
 Base/Py/PyObject.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Base/Py/PyObject.h b/Base/Py/PyObject.h
index b8d6ef2545c..52e56f1d519 100644
--- a/Base/Py/PyObject.h
+++ b/Base/Py/PyObject.h
@@ -3,7 +3,7 @@
 //  BornAgain: simulate and fit reflection and scattering
 //
 //! @file      Base/Py/PyObject.h
-//! @brief     PyObvject forward declaration.
+//! @brief     PyObject forward declaration.
 //!
 //! @homepage  http://www.bornagainproject.org
 //! @license   GNU General Public License v3 or higher (see COPYING)
-- 
GitLab


From c52b0d42438f5f798135df64d0a6adbd5d83ccf7 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 9 Nov 2021 17:09:44 +0100
Subject: [PATCH 2/3] improve class comment

---
 Device/Data/OutputData.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Device/Data/OutputData.h b/Device/Data/OutputData.h
index 5964545cde0..8f5cc78d017 100644
--- a/Device/Data/OutputData.h
+++ b/Device/Data/OutputData.h
@@ -26,7 +26,8 @@
 
 using std::size_t;
 
-//! Templated class to store data of type double or CumulativeValue in multi-dimensional space.
+//! Templated class to store data in multi-dimensional space.
+//! Used with type T = double, CumulativeValue, bool
 //! @ingroup tools
 
 template <class T> class OutputData {
-- 
GitLab


From 5a39f8c39b7efa7fbe8410032c0aeb2c3f4d2d73 Mon Sep 17 00:00:00 2001
From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de>
Date: Tue, 9 Nov 2021 17:13:10 +0100
Subject: [PATCH 3/3] prefer assert over runtime_error

---
 Device/Data/OutputData.cpp      |  3 +--
 Device/Data/OutputData.h        | 43 +++++++--------------------------
 auto/Wrap/doxygenDevice.i       |  2 +-
 auto/Wrap/libBornAgainDevice.py |  2 +-
 4 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/Device/Data/OutputData.cpp b/Device/Data/OutputData.cpp
index 2d8b6fd2563..a2a9d6ff166 100644
--- a/Device/Data/OutputData.cpp
+++ b/Device/Data/OutputData.cpp
@@ -38,8 +38,7 @@ template <> PyObject* OutputData<double>::getArray() const
     // creating standalone numpy array
     PyObject* pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE);
     delete[] ndimsizes_numpy;
-    if (pyarray == nullptr)
-        throw std::runtime_error("ExportOutputData() -> Panic in PyArray_SimpleNew");
+    ASSERT(pyarray);
 
     // getting pointer to data buffer of numpy array
     double* array_buffer = (double*)PyArray_DATA((PyArrayObject*)pyarray);
diff --git a/Device/Data/OutputData.h b/Device/Data/OutputData.h
index 8f5cc78d017..49a670dcfd4 100644
--- a/Device/Data/OutputData.h
+++ b/Device/Data/OutputData.h
@@ -293,10 +293,7 @@ template <class T> OutputData<double>* OutputData<T>::meanValues() const
 
 template <class T> void OutputData<T>::addAxis(const IAxis& new_axis)
 {
-    if (axisNameExists(new_axis.axisName()))
-        throw std::runtime_error("OutputData<T>::addAxis(const IAxis& new_axis) -> "
-                                 "Error! Attempt to add axis with already existing name '"
-                                 + new_axis.axisName() + "'");
+    ASSERT(!axisNameExists(new_axis.axisName()));
     if (new_axis.size() > 0) {
         m_axes.push_back(new_axis.clone());
         allocate();
@@ -306,10 +303,7 @@ template <class T> void OutputData<T>::addAxis(const IAxis& new_axis)
 template <class T>
 void OutputData<T>::addAxis(const std::string& name, size_t size, double start, double end)
 {
-    if (axisNameExists(name))
-        throw std::runtime_error("OutputData<T>::addAxis(std::string name) -> "
-                                 "Error! Attempt to add axis with already existing name '"
-                                 + name + "'");
+    ASSERT(!axisNameExists(name));
     FixedBinAxis new_axis(name, size, start, end);
     addAxis(new_axis);
 }
@@ -377,8 +371,7 @@ size_t OutputData<T>::getAxisBinIndex(size_t global_index, size_t i_selected_axi
             return result;
         remainder /= m_axes[i_axis]->size();
     }
-    throw std::runtime_error("OutputData<T>::getAxisBinIndex() -> "
-                             "Error! No axis with given number");
+    ASSERT(0);
 }
 
 template <class T>
@@ -391,20 +384,11 @@ template <class T>
 size_t OutputData<T>::toGlobalIndex(const std::vector<unsigned>& axes_indices) const
 {
     ASSERT(m_ll_data);
-    if (axes_indices.size() != m_ll_data->rank())
-        throw std::runtime_error("size_t OutputData<T>::toGlobalIndex() -> "
-                                 "Error! Number of coordinates must match rank of data structure");
+    ASSERT(axes_indices.size() == m_ll_data->rank());
     size_t result = 0;
     size_t step_size = 1;
     for (size_t i = m_ll_data->rank(); i > 0; --i) {
-        if (axes_indices[i - 1] >= m_axes[i - 1]->size()) {
-            std::ostringstream message;
-            message << "size_t OutputData<T>::toGlobalIndex() -> Error. Index ";
-            message << axes_indices[i - 1] << " is out of range. Axis ";
-            message << m_axes[i - 1]->axisName();
-            message << " size " << m_axes[i - 1]->size() << ".\n";
-            throw std::runtime_error(message.str());
-        }
+        ASSERT(axes_indices[i - 1] < m_axes[i - 1]->size());
         result += axes_indices[i - 1] * step_size;
         step_size *= m_axes[i - 1]->size();
     }
@@ -415,9 +399,7 @@ template <class T>
 size_t OutputData<T>::findGlobalIndex(const std::vector<double>& coordinates) const
 {
     ASSERT(m_ll_data);
-    if (coordinates.size() != m_ll_data->rank())
-        throw std::runtime_error("OutputData<T>::findClosestIndex() -> "
-                                 "Error! Number of coordinates must match rank of data structure");
+    ASSERT(coordinates.size() == m_ll_data->rank());
     std::vector<unsigned> axes_indexes;
     axes_indexes.resize(m_ll_data->rank());
     for (size_t i = 0; i < m_ll_data->rank(); ++i)
@@ -474,9 +456,7 @@ template <class T> void OutputData<T>::clear()
 
 template <class T> void OutputData<T>::setAllTo(const T& value)
 {
-    if (!m_ll_data)
-        throw std::runtime_error(
-            "OutputData::setAllTo() -> Error! Low-level data object was not yet initialized.");
+    ASSERT(m_ll_data);
     m_ll_data->setAll(value);
 }
 
@@ -545,10 +525,7 @@ template <class T> void OutputData<T>::allocate()
 
 template <class T> inline void OutputData<T>::setRawDataVector(const std::vector<T>& data_vector)
 {
-    if (data_vector.size() != getAllocatedSize())
-        throw std::runtime_error(
-            "OutputData<T>::setRawDataVector() -> Error! "
-            "setRawDataVector can only be called with a data vector of the correct size.");
+    ASSERT(data_vector.size() == getAllocatedSize());
     for (size_t i = 0; i < getAllocatedSize(); ++i)
         (*m_ll_data)[i] = data_vector[i];
 }
@@ -601,9 +578,7 @@ template <class T> size_t OutputData<T>::getAxisIndex(const std::string& axis_na
     for (size_t i = 0; i < m_axes.size(); ++i)
         if (m_axes[i]->axisName() == axis_name)
             return i;
-    throw std::runtime_error("OutputData<T>::getAxisIndex() -> "
-                             "Error! Axis with given name not found '"
-                             + axis_name + "'");
+    ASSERT(0);
 }
 
 template <class T> bool OutputData<T>::axisNameExists(const std::string& axis_name) const
diff --git a/auto/Wrap/doxygenDevice.i b/auto/Wrap/doxygenDevice.i
index 7afac3407d8..b60c988fe04 100644
--- a/auto/Wrap/doxygenDevice.i
+++ b/auto/Wrap/doxygenDevice.i
@@ -1737,7 +1737,7 @@ C++ includes: CoordSystem2D.h
 // File: classOutputData.xml
 %feature("docstring") OutputData "
 
-Templated class to store data of type double or  CumulativeValue in multi-dimensional space.
+Templated class to store data in multi-dimensional space. Used with type T = double,  CumulativeValue, bool
 
 C++ includes: OutputData.h
 ";
diff --git a/auto/Wrap/libBornAgainDevice.py b/auto/Wrap/libBornAgainDevice.py
index 17d72d219da..4014d89f187 100644
--- a/auto/Wrap/libBornAgainDevice.py
+++ b/auto/Wrap/libBornAgainDevice.py
@@ -2217,7 +2217,7 @@ class IntensityData(object):
     r"""
 
 
-    Templated class to store data of type double or  CumulativeValue in multi-dimensional space.
+    Templated class to store data in multi-dimensional space. Used with type T = double,  CumulativeValue, bool
 
     C++ includes: OutputData.h
 
-- 
GitLab