-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
BUG: np.random.Generator cannot be unpickled using 3rd party bit generators #22012
Copy link
Copy link
Closed
Closed
Copy link
Labels
Description
Describe the issue:
The unpickling mechanism uses a hard-coded list of bit generators when unpickling a generator instance. Because of this, it cannot be used with 3rd party bit generators, or, if the name of the 3rd party bit generator is the same as the NumPy bit generator, it will unpickle using a different class than the original bit generator class
Reproduce the code example:
import numpy as np
import randomgen as rg
import pickle
# Generator(MT64)
g = np.random.Generator(rg.MT64())
pickle.loads(pickle.dumps(g))Error message:
Traceback (most recent call last):
File "C:\git\randomgen\exp.py", line 7, in <module>
pickle.loads(pickle.dumps(g))
File "c:\git\numpy\numpy\random\_pickle.py", line 52, in __generator_ctor
raise ValueError(
ValueError: MT64 is not a known NumPy BitGenerator class.NumPy/Python version information:
1.24.0.dev0+559.g5ba36b700 3.10.4 | packaged by conda-forge | (main, Mar 30 2022, 08:38:02) [MSC v.1916 64 bit (AMD64)]
Reactions are currently unavailable