@@ -265,23 +265,52 @@ inline void store_chunk(
265265 " in record component (" ) +
266266 std::to_string (r_shape.size ()) + std::string (" D)" ));
267267
268- for (auto d = 0 ; d < a. ndim (); ++d )
268+ if (auto joined_dim = r. joinedDimension (); joined_dim. has_value () )
269269 {
270- // selection causes overflow of r
271- if (offset.at (d) + extent.at (d) > r_shape.at (d))
272- throw py::index_error (
273- std::string (" slice " ) + std::to_string (offset.at (d)) +
274- std::string (" :" ) + std::to_string (extent.at (d)) +
275- std::string (" is out of bounds for axis " ) + std::to_string (d) +
276- std::string (" with size " ) + std::to_string (r_shape.at (d)));
277- // underflow of selection in r for given a
278- if (s_shape.at (d) != std::uint64_t (a.shape ()[d]))
279- throw py::index_error (
280- std::string (" size of chunk (" ) + std::to_string (a.shape ()[d]) +
281- std::string (" ) for axis " ) + std::to_string (d) +
282- std::string (" does not match selection " ) +
283- std::string (" size in record component (" ) +
284- std::to_string (s_extent.at (d)) + std::string (" )" ));
270+ for (py::ssize_t d = 0 ; d < a.ndim (); ++d)
271+ {
272+ // selection causes overflow of r
273+ if (d != py::ssize_t (*joined_dim) && extent.at (d) != r_shape.at (d))
274+ throw py::index_error (
275+ std::string (" selection for axis " ) + std::to_string (d) +
276+ " of record component with joined dimension " +
277+ std::to_string (*joined_dim) +
278+ " must be equivalent to its global extent " +
279+ std::to_string (extent.at (d)) + " , but was " +
280+ std::to_string (r_shape.at (d)) + " ." );
281+ // underflow of selection in r for given a
282+ if (s_shape.at (d) != std::uint64_t (a.shape ()[d]))
283+ throw py::index_error (
284+ std::string (" size of chunk (" ) +
285+ std::to_string (a.shape ()[d]) + std::string (" ) for axis " ) +
286+ std::to_string (d) +
287+ std::string (" does not match selection " ) +
288+ std::string (" size in record component (" ) +
289+ std::to_string (s_extent.at (d)) + std::string (" )" ));
290+ }
291+ }
292+ else
293+ {
294+ for (auto d = 0 ; d < a.ndim (); ++d)
295+ {
296+ // selection causes overflow of r
297+ if (offset.at (d) + extent.at (d) > r_shape.at (d))
298+ throw py::index_error (
299+ std::string (" slice " ) + std::to_string (offset.at (d)) +
300+ std::string (" :" ) + std::to_string (extent.at (d)) +
301+ std::string (" is out of bounds for axis " ) +
302+ std::to_string (d) + std::string (" with size " ) +
303+ std::to_string (r_shape.at (d)));
304+ // underflow of selection in r for given a
305+ if (s_shape.at (d) != std::uint64_t (a.shape ()[d]))
306+ throw py::index_error (
307+ std::string (" size of chunk (" ) +
308+ std::to_string (a.shape ()[d]) + std::string (" ) for axis " ) +
309+ std::to_string (d) +
310+ std::string (" does not match selection " ) +
311+ std::string (" size in record component (" ) +
312+ std::to_string (s_extent.at (d)) + std::string (" )" ));
313+ }
285314 }
286315
287316 check_buffer_is_contiguous (a);
0 commit comments