Skip to content

Commit

Permalink
ENH Remove use of std::random_shuffle
Browse files Browse the repository at this point in the history
This has been removed in C++17

closes #146
  • Loading branch information
luispedro committed Mar 22, 2024
1 parent a88b95d commit 3e927b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
@@ -1,3 +1,6 @@
Version 1.4.14 2024-03-22 by luispedro
* Update for C++17 (remove use of std::random_shuffle)

Version 1.4.13 2022-06-28 by luispedro
* Fix freeimage testing (and make freeimage loading more robust, see #129)
* Add GIL fixed (which triggered crashes in newer NumPy versions)
Expand Down
6 changes: 4 additions & 2 deletions mahotas/_morph.cpp
@@ -1,4 +1,4 @@
// Copyright (C) 2008-2019, Luis Pedro Coelho <luis@luispedro.org>
// Copyright (C) 2008-2024, Luis Pedro Coelho <luis@luispedro.org>
// vim: set ts=4 sts=4 sw=4 expandtab smartindent:
//
// License: MIT
Expand All @@ -9,6 +9,7 @@
#include <cstdio>
#include <limits>
#include <iostream>
#include <random>

#include "numpypp/array.hpp"
#include "numpypp/dispatch.hpp"
Expand Down Expand Up @@ -861,7 +862,8 @@ void hitmiss(numpy::aligned_array<T> res, const numpy::aligned_array<T>& input,
// This is a micro-optimisation for templates with structure
// It makes it more likely that matching will fail earlier
// in uniform regions than otherwise would be the case.
std::random_shuffle(neighbours.begin(), neighbours.end());
std::mt19937 g(12345);
std::shuffle(neighbours.begin(), neighbours.end(), g);
numpy::index_type slack = 0;
for (npy_intp i = 0; i != N; ++i) {
while (!slack) {
Expand Down

0 comments on commit 3e927b4

Please sign in to comment.