-
Notifications
You must be signed in to change notification settings - Fork 14
Add documentation for patching utilities and interfaces
#107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ndgrigorian
wants to merge
16
commits into
master
Choose a base branch
from
document-numpy-interface
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
8798c60
add documentation for patching utilities and interfaces
ndgrigorian 9456716
show inherited members in MKLRandomState and RandomState
ndgrigorian 3fca0b6
add sections to index.rst about interfaces and patching
ndgrigorian f06e30d
address review comments
ndgrigorian 85b3c4d
use ..autofunction over autosummary for exported methods in interface…
ndgrigorian ac526c1
fix indentation in numpy_random.get_state
ndgrigorian 5aabff2
change compatibility notice formatting
ndgrigorian 98eedcc
update compatibility notice in MKLRandomState
ndgrigorian c157fd6
add linter flag removal to conf.py docstring rendering
ndgrigorian cc9274c
disable blanket-noqa check in conf.py
ndgrigorian dfc9210
simplfiy reference guide card description
ndgrigorian 8e84bf9
add current_module to properly link to functions in interfaces docs
ndgrigorian 0524b26
do not attempt to list in RandomState docstring
ndgrigorian 42f9b70
fix indentation in get_state
ndgrigorian f98e9d5
remove uses of .. note:: in docs for now
ndgrigorian 0c4d814
fix get_state docstrings
ndgrigorian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,15 @@ | ||
| .. _fullapi: | ||
|
|
||
| Class MKLRandomState | ||
| ==================== | ||
|
|
||
| .. autoclass:: mkl_random.MKLRandomState | ||
| :members: | ||
| :inherited-members: | ||
|
|
||
| Class RandomState | ||
| ================= | ||
|
|
||
| .. autoclass:: mkl_random.RandomState | ||
| :members: | ||
| :inherited-members: | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| .. _interfaces: | ||
|
|
||
| :mod:`mkl_random.interfaces` | ||
| ==================================================== | ||
|
|
||
| :mod:`mkl_random.interfaces` provides drop-in replacements for supported random number generation | ||
| modules using :mod:`mkl_random` implementations. Currently, only a NumPy interface is provided, | ||
| but more may be added in the future. | ||
|
|
||
|
|
||
ndgrigorian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .. _numpy_random_interface: | ||
|
|
||
| NumPy interface --- :mod:`mkl_random.interfaces.numpy_random` | ||
| ------------------------------------------------------------- | ||
|
|
||
| :mod:`mkl_random.interfaces.numpy_random` is a drop-in replacement for the legacy portion of | ||
| `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_. | ||
|
|
||
| .. currentmodule:: mkl_random.interfaces.numpy_random | ||
|
|
||
| .. note:: | ||
| While the API is the same, :mod:`mkl_random.interfaces.numpy_random` is **not** seed-compatible | ||
| with `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_. Given the same seed, the two modules | ||
| will produce different sequences. The output of :func:`get_state` and accepted input to :func:`set_state` may also differ. | ||
| It is not recommended to provide the output of :func:`get_state` from one module to :func:`set_state` of the other. | ||
| There also may be differences in some edge cases, such as behavior of functions when given specific inputs. | ||
|
|
||
|
|
||
| RandomState class | ||
| ^^^^^^^^^^^^^^^^^ | ||
|
|
||
| .. autoclass:: mkl_random.interfaces.numpy_random.RandomState | ||
| :members: | ||
| :undoc-members: | ||
ndgrigorian marked this conversation as resolved.
Show resolved
Hide resolved
ndgrigorian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| Functions | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| **Seeding and state functions:** | ||
|
|
||
| .. autofunction:: mkl_random.interfaces.numpy_random.seed | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.get_state | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.set_state | ||
|
|
||
| **Simple random data:** | ||
|
|
||
| Similar to NumPy, the methods of :class:`RandomState` are exported as functions in the module. | ||
| Their usage is discouraged, as they are implemented from a global instance of :class:`RandomState`, | ||
| which means results may change across calls. | ||
|
|
||
| .. autofunction:: mkl_random.interfaces.numpy_random.rand | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.randn | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.randint | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.random_integers | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.random_sample | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.random | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.ranf | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.choice | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.bytes | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.sample | ||
|
|
||
| **Permutations:** | ||
|
|
||
| .. autofunction:: mkl_random.interfaces.numpy_random.shuffle | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.permutation | ||
|
|
||
| **Distributions:** | ||
|
|
||
| .. autofunction:: mkl_random.interfaces.numpy_random.beta | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.binomial | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.chisquare | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.dirichlet | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.exponential | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.f | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.gamma | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.geometric | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.gumbel | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.hypergeometric | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.laplace | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.logistic | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.lognormal | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.logseries | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.multinomial | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.multivariate_normal | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.negative_binomial | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.noncentral_chisquare | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.noncentral_f | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.normal | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.pareto | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.poisson | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.power | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.rayleigh | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.standard_cauchy | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.standard_exponential | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.standard_gamma | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.standard_normal | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.standard_t | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.triangular | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.uniform | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.vonmises | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.wald | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.weibull | ||
| .. autofunction:: mkl_random.interfaces.numpy_random.zipf | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| .. _patching: | ||
|
|
||
| Patching `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_ | ||
| ============================ | ||
|
|
||
| :mod:`mkl_random` can temporarily replace functions and classes in `numpy.random <https://numpy.org/doc/stable/reference/random/legacy.html>`_ with | ||
| :mod:`mkl_random` implementations from the :ref:`numpy interface <numpy_random_interface>`. | ||
|
|
||
|
|
||
| Functions | ||
| --------- | ||
|
|
||
| .. autofunction:: mkl_random.patch_numpy_random | ||
ndgrigorian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| .. autofunction:: mkl_random.restore_numpy_random | ||
|
|
||
| .. autofunction:: mkl_random.is_patched | ||
|
|
||
|
|
||
| Context manager | ||
| --------------- | ||
|
|
||
| .. autoclass:: mkl_random.mkl_random | ||
| :members: | ||
|
|
||
| :class:`mkl_random.mkl_random` is both a context manager and a decorator, making it possible to | ||
| scope the patch to a block of code or a function. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.