Skip to content

Commit fbd76e0

Browse files
jeandetclaude
andcommitted
fix(datasource): warn on rows==0 shape lies too, not only rows!=0
The row-major ctor's diagnostic was gated on rows != 0, so rows == 0 with non-empty keys dropped data silently — inconsistent with the other mismatch paths and with the 2D source's any-input-non-empty gate. Genuinely empty input (rows == 0, no keys) stays silent. Review follow-up on PR #31. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 2adfaaf commit fbd76e0

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/datasource/row-major-multi-datasource.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ class QCPRowMajorMultiDataSource final : public QCPAbstractMultiDataSource {
8585
&& static_cast<int>(keys.size()) == rows && values != nullptr;
8686
if (!valid)
8787
{
88-
if (rows != 0)
88+
// Genuinely empty input (rows == 0, no keys) stays silent; any
89+
// other combination is a shape lie worth a diagnostic.
90+
if (rows != 0 || !keys.empty())
8991
qWarning("QCPRowMajorMultiDataSource: invalid shape (rows=%d, columns=%d, "
9092
"stride=%d, keys=%zu, values=%p) — dropping data",
9193
rows, columns, stride, keys.size(),

tests/auto/test-multi-datasource/test-multi-datasource.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,15 @@ void TestMultiDataSource::rowMajorInvalidShapeDegradesToEmpty()
486486
std::span<const double>(keys), nullptr, 3, 2, 2);
487487
QCOMPARE(src.size(), 0);
488488
}
489+
{
490+
// rows == 0 with non-empty keys is a shape lie, not a genuinely
491+
// empty source: it must warn like the other mismatch paths
492+
QTest::ignoreMessage(QtWarningMsg,
493+
QRegularExpression("QCPRowMajorMultiDataSource: invalid shape"));
494+
QCPRowMajorMultiDataSource<double, double> src(
495+
std::span<const double>(keys), values.data(), 0, 2, 2);
496+
QCOMPARE(src.size(), 0);
497+
}
489498
}
490499

491500
// Helper: build an L1 cache with uniform keys and per-column values

0 commit comments

Comments
 (0)