bugfix for wrap flag: structure was being tagged as wrapped because duplicated cell had an unconnected cell
This commit is contained in:
parent
296dacd82a
commit
2d5ff2fbe1
10
field.py
10
field.py
|
|
@ -685,10 +685,12 @@ class BinaryFieldNd:
|
||||||
for source_ in np.unique(lab_hi[li]):
|
for source_ in np.unique(lab_hi[li]):
|
||||||
map_[source_] = 0
|
map_[source_] = 0
|
||||||
else:
|
else:
|
||||||
sl_lo = tuple(slice(0,1) if ii==axis else slice(None) for ii in range(self._ndim))
|
sl_lo = tuple(slice(0,1) if ii==axis else slice(None) for ii in range(self._ndim))
|
||||||
sl_hi = tuple(slice(-1,None) if ii==axis else slice(None) for ii in range(self._ndim))
|
sl_hi = tuple(slice(-1,None) if ii==axis else slice(None) for ii in range(self._ndim))
|
||||||
|
sl_pre = tuple(slice(-2,-1) if ii==axis else slice(None) for ii in range(self._ndim))
|
||||||
lab_lo = labels_[sl_lo]
|
lab_lo = labels_[sl_lo]
|
||||||
lab_hi = labels_[sl_hi]
|
lab_hi = labels_[sl_hi]
|
||||||
|
lab_pre = np.unique(labels_[sl_pre]) # all labels in last (unwrapped) slice
|
||||||
# Initialize array to keep track of wrapping
|
# Initialize array to keep track of wrapping
|
||||||
wrap_[axis] = np.zeros(nlabels_+1,dtype=bool)
|
wrap_[axis] = np.zeros(nlabels_+1,dtype=bool)
|
||||||
# Determine new label and map
|
# Determine new label and map
|
||||||
|
|
@ -703,12 +705,14 @@ class BinaryFieldNd:
|
||||||
while target_ != map_[target_]: # map it recursively
|
while target_ != map_[target_]: # map it recursively
|
||||||
target_ = map_[target_]
|
target_ = map_[target_]
|
||||||
map_[source_] = target_
|
map_[source_] = target_
|
||||||
wrap_[axis][target_] = True
|
if source_ in lab_pre: # check if source is not a ghost
|
||||||
|
wrap_[axis][target_] = True
|
||||||
# Remove gaps from target mapping
|
# Remove gaps from target mapping
|
||||||
idx_,map_ = np.unique(map_,return_index=True,return_inverse=True)[1:3]
|
idx_,map_ = np.unique(map_,return_index=True,return_inverse=True)[1:3]
|
||||||
# Relabel and remove padding
|
# Relabel and remove padding
|
||||||
labels_ = map_[labels_[sl_pad]]
|
labels_ = map_[labels_[sl_pad]]
|
||||||
nlabels_ = np.max(map_)
|
nlabels_ = np.max(map_)
|
||||||
|
assert nlabels_==len(idx_)-1, "DEBUG assertion"
|
||||||
for axis in range(self._ndim):
|
for axis in range(self._ndim):
|
||||||
if wrap_[axis] is not None:
|
if wrap_[axis] is not None:
|
||||||
wrap_[axis] = wrap_[axis][idx_]
|
wrap_[axis] = wrap_[axis][idx_]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue