Skip to content

Commit

Permalink
Unofficial support for np 1.17 rnd.Generator (#26)
Browse files Browse the repository at this point in the history
* Unofficial support for np 1.17 rnd.Generator
  • Loading branch information
N-Wouda authored Mar 29, 2020
1 parent 115cf93 commit ce3e64a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion alns/criteria/SimulatedAnnealing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,11 @@ def accept(self, rnd, best, current, candidate):
self.step,
self.method))

return probability >= rnd.random_sample()
# TODO the following is in preparation of the new numpy Generator
# interface, which deprecates random_sample() in favour of random().
# ALNS does not yet formally support Generators, but unofficially it
# should work in most cases.
try:
return probability >= rnd.random()
except AttributeError:
return probability >= rnd.random_sample()
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MAJOR = 1
MINOR = 2
MAINTENANCE = 4
MAINTENANCE = 5
MODIFIER = ""

VERSION = "{0}.{1}.{2}{3}".format(MAJOR, MINOR, MAINTENANCE, MODIFIER)
Expand Down

0 comments on commit ce3e64a

Please sign in to comment.