statlab / cryptorandom

Pseudorandom number generators based on cryptographic hash functions
https://statlab.github.io/cryptorandom/
BSD 2-Clause "Simplified" License
3 stars 10 forks source link

Replace deprecated np.int #52

Closed jarrodmillman closed 3 years ago

jarrodmillman commented 3 years ago

@pbstark @akglazer I believe this is the last issue before we are ready to release new versions of cryptorandom and permute. Let me know if my change makes sense or whether we should use something else to replace np.int (details below).

np.int is deprecated https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

You can read more in the above link, but this is the recommendation:

For np.int a direct replacement with np.int_ or int is also good and will not change behavior, but the precision will continue to depend on the computer and operating system. If you want to be more explicit and review the current use, you have the following alternatives:

- np.int64 or np.int32 to specify the precision exactly. This ensures that results cannot depend on the computer or operating system.
- np.int_ or int (the default), but be aware that it depends on the computer and operating system.
- The C types: np.cint (int), np.int_ (long), np.longlong.
- np.intp which is 32bit on 32bit machines 64bit on 64bit machines. This can be the best type to use for indexing.

I went with np.int64, but I am not sure that is what you want. The advantage of using np.int64 is that behavior should be consistent across computers/operating systems. This shouldn't change behavior on Mac or Linux, but Windows will now use 64 bit integers (instead of 32 bit).