connected-components-3d icon indicating copy to clipboard operation
connected-components-3d copied to clipboard

`connected_components` fails on immutable arrays

Open vovaf709 opened this issue 1 year ago • 2 comments

import numpy as np
from cc3d import connected_components

x = np.ones(3)
x.flags.writeable = False

connected_components(x)  # Fails with `ValueError: buffer source array is read-only`

vovaf709 avatar Jul 30 '24 14:07 vovaf709

I think fix is really easy, I'll try to fix it by myself

vovaf709 avatar Jul 30 '24 14:07 vovaf709

I figured it out, but the fix is not super easy. The problem is that adding trivial dimensions up to 3 creates a view and owndata is False. You can avoid this problem with using a 3D image e.g. np.ones([3,1,1]). I'll have to spend some time figuring out the right way to solve this.

william-silversmith avatar Jul 30 '24 23:07 william-silversmith