Skip to content

Commit

Permalink
Fix the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Aug 28, 2024
1 parent dfe524b commit 37ab01f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions vigranumpy/src/core/segmentation.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1169,11 +1169,21 @@ pythonUnique(NumpyArray<NDIM, Singleband<VoxelType> > src, bool sort=true)

NumpyArray<1, VoxelType> result;
result.reshape( Shape1(labelset.size()) );
std::copy( labelset.begin(), labelset.end(), result.begin() );

if (sort)
{
std::sort( result.begin(), result.end() );
// I (hmaarrfk) had a lot of trouble getting the derencing poiter
// implementation for std::sort to work
// In 2022 this started to cause compilation problems in Windows
// and in 2024 it started to manifest as porblems with clang 16
// https://github.com/ukoethe/vigra/issues/525
// We therefore create a temporary copy to a std::vector
// then copy the sorted result back
std::vector<VoxelType> sorted_result(labelset.begin(), labelset.end());
std::sort( sorted_result.begin(), sorted_result.end() );
std::copy( sorted_result.begin(), sorted_result.end(), result.begin() );
} else {
std::copy( labelset.begin(), labelset.end(), result.begin() );
}
return result;
}
Expand Down

0 comments on commit 37ab01f

Please sign in to comment.