BlockLayout2D.to_dense: restore hole-only NaN fill guard
cc64abc dropped the guard, so full layouts with integer arrays raised on
an empty NaN assignment (regression caught by test_to_dense_dtype_contract).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
cc64abcafe
commit
68ecaf9e81
1 file changed
+2
-1
@@ -330,7 +330,8 @@ class BlockLayout2D:
|
|||||||
raise ValueError("a layout with holes unpacks floating arrays only (holes are NaN)")
|
raise ValueError("a layout with holes unpacks floating arrays only (holes are NaN)")
|
||||||
ob, oc = np.divmod(self.owner.ravel()[owned].astype(np.intp), flat.shape[2])
|
ob, oc = np.divmod(self.owner.ravel()[owned].astype(np.intp), flat.shape[2])
|
||||||
dense = np.empty((NQ, owned.size), dtype=blocked.dtype)
|
dense = np.empty((NQ, owned.size), dtype=blocked.dtype)
|
||||||
dense[:, ~owned] = np.nan
|
if not owned.all(): # even an empty NaN assignment fails for integer dtypes
|
||||||
|
dense[:, ~owned] = np.nan
|
||||||
dense[:, owned] = flat[ob, :, oc].T
|
dense[:, owned] = flat[ob, :, oc].T
|
||||||
return dense.reshape(NQ, *self.shape)
|
return dense.reshape(NQ, *self.shape)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user