Skip to content

Commit

Permalink
Test making wrapper converter constant.
Browse files Browse the repository at this point in the history
Ubuntu 24 complained, probably due to a newer version of SWIG?
  • Loading branch information
luciansmith committed Jan 17, 2025
1 parent 18e4589 commit b4e7db3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
20 changes: 10 additions & 10 deletions source/Matrix3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ namespace rr {
* @param i indexes the number of elements in each row vector j; i in 0, 1, ..., xMax
* @return A scalar DataType object at index k, j, i of this Matrix3D<DataType>.
*/
DataType slice(int k, int j, int i) {
DataType slice(int k, int j, int i) const {
if (k > numZ()) {
std::ostringstream err;
err << "requested kth index " << k << " from a Matrix3D with " << numZ()
Expand All @@ -175,9 +175,9 @@ namespace rr {
<< " elements in the hight (y) direction";
throw std::invalid_argument(err.str());
}
std::vector<std::vector<DataType>> submatrix = data_[k].getValues();
return data_[k][j][i];// .getValues();
// j indicates which row, i indicates which column
return submatrix[j][i];
//return submatrix[j][i];
}

/**
Expand Down Expand Up @@ -221,7 +221,7 @@ namespace rr {
* @brief get number of rows in this 3D matrix
* @details x is rows, y is columns, z is depth.
*/
int numRows() {
int numRows() const {
if (data_.empty())
return 0;
return data_[0].numRows();
Expand All @@ -231,7 +231,7 @@ namespace rr {
* @brief get number of columns in this 3D matrix
* @details if x is rows, y is columns, z is depth.
*/
int numCols() {
int numCols() const {
if (data_.empty())
return 0;
return data_[0].numCols();
Expand All @@ -241,7 +241,7 @@ namespace rr {
* @brief get number of matrices in this 3D matrix
* @details if x is rows, y is columns, z is depth.
*/
int numZ() {
int numZ() const {
if (index_.empty())
return 0;
return index_.size();
Expand Down Expand Up @@ -270,15 +270,15 @@ namespace rr {
/**
* @brief return the row names for this Matrix3D
*/
std::vector<std::string> getRowNames() {
return slice(0).rowNames;
std::vector<std::string> getRowNames() const {
return data_[0].rowNames;
}

/**
* @brief return the column names for this Matrix3D
*/
std::vector<std::string> getColNames() {
return slice(0).colNames;
std::vector<std::string> getColNames() const {
return data_[0].colNames;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion wrappers/Python/roadrunner/PyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,7 +1777,7 @@ namespace rr {
}


Matrix3DToNumpy::Matrix3DToNumpy(Matrix3DToNumpy::DoubleMatrix3D &matrix)
Matrix3DToNumpy::Matrix3DToNumpy(const Matrix3DToNumpy::DoubleMatrix3D &matrix)
: matrix_(matrix) {}

PyObject *Matrix3DToNumpy::convertData() {
Expand Down
4 changes: 2 additions & 2 deletions wrappers/Python/roadrunner/PyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ namespace rr {
public:
using DoubleMatrix3D = rr::Matrix3D<double, double>;

explicit Matrix3DToNumpy(DoubleMatrix3D &matrix);
explicit Matrix3DToNumpy(const DoubleMatrix3D &matrix);

/**
* @brief converts the index data field of the Double3DMatrix
Expand Down Expand Up @@ -314,7 +314,7 @@ namespace rr {
/**
* @brief the Matrix3D<double, double> to convert
*/
DoubleMatrix3D &matrix_;
const DoubleMatrix3D &matrix_;
};


Expand Down

0 comments on commit b4e7db3

Please sign in to comment.