Skip to content
Snippets Groups Projects
Commit b40fbe3f authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Show some values if few cols but too many rows

parent 69b2ea72
No related branches found
No related tags found
1 merge request!355Memory Viewer: Improve display of NdArrays, fix passing -1 as num rows/cols
......@@ -81,18 +81,7 @@ namespace armarx::aron
{
auto d = data::NDArray::DynamicCastAndCheck(data);
auto base = [this, &d]()
{
value << "shape " << aron::data::NDArray::DimensionsToString(d->getShape())
<< ", type '" << d->getType() << "'";
};
if (std::max(d->getShape().at(0), d->getShape().at(1)) > 10)
{
// Just show the shape.
base();
}
else if (d->getType() == "float")
if (d->getType() == "float")
{
setStreamPrecision();
processMatrix<float>(*d);
......@@ -104,19 +93,48 @@ namespace armarx::aron
}
else
{
base();
printShape(*d);
}
}
void
DataDisplayVisitor::printShape(const data::NDArray& d)
{
value << "shape " << aron::data::NDArray::DimensionsToString(d.getShape()) << ", type '"
<< d.getType() << "'";
}
template <typename ScalarT>
void
DataDisplayVisitor::processMatrix(const data::NDArray& data)
{
Eigen::Map<Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic>> m(
reinterpret_cast<ScalarT*>(data.getData()),
data.getShape().at(0),
data.getShape().at(1));
value << m.format(eigenIof);
const int rows = data.getShape().at(0);
const int cols = data.getShape().at(1);
const Eigen::Map<Eigen::Matrix<ScalarT, Eigen::Dynamic, Eigen::Dynamic>> m(
reinterpret_cast<ScalarT*>(data.getData()), rows, cols);
const int maxRows = 10;
const int maxCols = 10;
if (cols > maxCols)
{
printShape(data);
}
else if (rows > maxRows)
{
int shownRows = 2;
value << "(";
printShape(data);
value << ")\n"
<< m.block(0, 0, shownRows, cols) << "\n...\n"
<< m.block(rows - shownRows, 0, shownRows, cols);
}
else
{
value << m.format(eigenIof);
}
}
......
......@@ -31,6 +31,8 @@ namespace armarx::aron
private:
template <typename ScalarT>
void processMatrix(const data::NDArray& data);
void printShape(const data::NDArray& data);
};
} // namespace armarx::aron
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment