Skip to content

Commit b7c7250

Browse files
committed
fix: handle empty blocks in preserve_lobound()
If any of the extents are zero (lb == up), do not update the lobound, just no-op. But return Derived& to not break the API.
1 parent 386b568 commit b7c7250

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/TiledArray/expressions/blk_tsr_expr.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,13 @@ class BlkTsrExprBase : public Expr<Derived> {
313313

314314
/// Sets result trange lobound such that the tile lobounds are not changed
315315
Derived& preserve_lobound() {
316-
return set_trange_lobound(
317-
array_.trange().make_tile_range(lower_bound()).lobound());
316+
// only set lobound if *all* dimensions have non-zero extents
317+
// so compare lower and upper bounds
318+
if (ranges::equal(lower_bound_, upper_bound_, std::less<>{})) {
319+
return set_trange_lobound(
320+
array_.trange().make_tile_range(lower_bound()).lobound());
321+
}
322+
return static_cast<Derived&>(*this);
318323
}
319324

320325
/// @return optional to result trange lobound; if null, the result trange

0 commit comments

Comments
 (0)