Skip to content

Commit 219e1d8

Browse files
committed
Fix typing issues with load/store_chunk in Python
1 parent d80b5a6 commit 219e1d8

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/binding/python/RecordComponent.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,14 @@ inline void store_chunk(
489489

490490
check_buffer_is_contiguous(a);
491491

492-
// dtype_from_numpy(a.dtype())
492+
if (!dtype_to_numpy(r.getDatatype()).is(a.dtype()))
493+
{
494+
std::stringstream err;
495+
err << "Attempting store from Python array of type '"
496+
<< dtype_from_numpy(a.dtype())
497+
<< "' into Record Component of type '" << r.getDatatype() << "'.";
498+
throw error::WrongAPIUsage(err.str());
499+
}
493500
switchDatasetType<StoreChunkFromPythonArray>(
494501
r.getDatatype(), r, a, offset, extent);
495502
}
@@ -770,6 +777,15 @@ inline void load_chunk(
770777

771778
check_buffer_is_contiguous(a);
772779

780+
if (!dtype_to_numpy(r.getDatatype()).is(a.dtype()))
781+
{
782+
std::stringstream err;
783+
err << "Attempting load into Python array of type '"
784+
<< dtype_from_numpy(a.dtype())
785+
<< "' from Record Component of type '" << r.getDatatype() << "'.";
786+
throw error::WrongAPIUsage(err.str());
787+
}
788+
773789
switchDatasetType<LoadChunkIntoPythonArray>(
774790
r.getDatatype(), r, a, offset, extent);
775791
}

0 commit comments

Comments
 (0)