diff --git a/src/RecordComponent.cpp b/src/RecordComponent.cpp index 9a5c2b6b04..a57f1d8f97 100644 --- a/src/RecordComponent.cpp +++ b/src/RecordComponent.cpp @@ -272,7 +272,7 @@ void RecordComponent::flush( { // The check for !written() is technically not needed, just // defensive programming against internal bugs that go on us. - if (!written() && rc.m_chunks.empty()) + if (!written() && rc.m_chunks.empty() && !rc.m_isConstant) { // No data written yet, just accessed the object so far without // doing anything @@ -283,7 +283,8 @@ void RecordComponent::flush( { throw error::WrongAPIUsage( "[RecordComponent] Must specify dataset type and extent " - "before flushing (see RecordComponent::resetDataset())."); + "before flushing or setting a constant value (see " + "RecordComponent::resetDataset())."); } } if (!containsAttribute("unitSI")) diff --git a/test/python/unittest/API/APITest.py b/test/python/unittest/API/APITest.py index f7514d8c2c..24dfec4051 100644 --- a/test/python/unittest/API/APITest.py +++ b/test/python/unittest/API/APITest.py @@ -109,6 +109,8 @@ def refcountingCreateData(self): for dim in ["x", "y"]: # Do not bother with a positionOffset position_offset = e["positionOffset"][dim] + position_offset.reset_dataset( + io.Dataset(np.dtype("int"), [100])) position_offset.make_constant(0) position = e["position"][dim]