about summary refs log tree commit diff
path: root/.venv/lib/python3.12/site-packages/numpy/random/_pickle.py
diff options
context:
space:
mode:
authorS. Solomon Darnell2025-03-28 21:52:21 -0500
committerS. Solomon Darnell2025-03-28 21:52:21 -0500
commit4a52a71956a8d46fcb7294ac71734504bb09bcc2 (patch)
treeee3dc5af3b6313e921cd920906356f5d4febc4ed /.venv/lib/python3.12/site-packages/numpy/random/_pickle.py
parentcc961e04ba734dd72309fb548a2f97d67d578813 (diff)
downloadgn-ai-4a52a71956a8d46fcb7294ac71734504bb09bcc2.tar.gz
two version of R2R are here HEAD master
Diffstat (limited to '.venv/lib/python3.12/site-packages/numpy/random/_pickle.py')
-rw-r--r--.venv/lib/python3.12/site-packages/numpy/random/_pickle.py80
1 files changed, 80 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/numpy/random/_pickle.py b/.venv/lib/python3.12/site-packages/numpy/random/_pickle.py
new file mode 100644
index 00000000..07399372
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/numpy/random/_pickle.py
@@ -0,0 +1,80 @@
+from .mtrand import RandomState
+from ._philox import Philox
+from ._pcg64 import PCG64, PCG64DXSM
+from ._sfc64 import SFC64
+
+from ._generator import Generator
+from ._mt19937 import MT19937
+
+BitGenerators = {'MT19937': MT19937,
+                 'PCG64': PCG64,
+                 'PCG64DXSM': PCG64DXSM,
+                 'Philox': Philox,
+                 'SFC64': SFC64,
+                 }
+
+
+def __bit_generator_ctor(bit_generator_name='MT19937'):
+    """
+    Pickling helper function that returns a bit generator object
+
+    Parameters
+    ----------
+    bit_generator_name : str
+        String containing the name of the BitGenerator
+
+    Returns
+    -------
+    bit_generator : BitGenerator
+        BitGenerator instance
+    """
+    if bit_generator_name in BitGenerators:
+        bit_generator = BitGenerators[bit_generator_name]
+    else:
+        raise ValueError(str(bit_generator_name) + ' is not a known '
+                                                   'BitGenerator module.')
+
+    return bit_generator()
+
+
+def __generator_ctor(bit_generator_name="MT19937",
+                     bit_generator_ctor=__bit_generator_ctor):
+    """
+    Pickling helper function that returns a Generator object
+
+    Parameters
+    ----------
+    bit_generator_name : str
+        String containing the core BitGenerator's name
+    bit_generator_ctor : callable, optional
+        Callable function that takes bit_generator_name as its only argument
+        and returns an instantized bit generator.
+
+    Returns
+    -------
+    rg : Generator
+        Generator using the named core BitGenerator
+    """
+    return Generator(bit_generator_ctor(bit_generator_name))
+
+
+def __randomstate_ctor(bit_generator_name="MT19937",
+                       bit_generator_ctor=__bit_generator_ctor):
+    """
+    Pickling helper function that returns a legacy RandomState-like object
+
+    Parameters
+    ----------
+    bit_generator_name : str
+        String containing the core BitGenerator's name
+    bit_generator_ctor : callable, optional
+        Callable function that takes bit_generator_name as its only argument
+        and returns an instantized bit generator.
+
+    Returns
+    -------
+    rs : RandomState
+        Legacy RandomState using the named core BitGenerator
+    """
+
+    return RandomState(bit_generator_ctor(bit_generator_name))