diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-11-27 12:15:27 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-27 12:15:27 -0800 |
commit | 3fcf144be4939a6a785dc80b75189c2e05d6bd22 (patch) | |
tree | dc35c9d9142fceb8702def0789cd0d047a5cd9b2 /doc/source/reference/random | |
parent | d37908878e83d9799fa771863b58f4d7c5d38a93 (diff) | |
parent | e0519fe66c832c08b07ad2a68037cac901fed4f7 (diff) | |
download | numpy-3fcf144be4939a6a785dc80b75189c2e05d6bd22.tar.gz |
Merge pull request #14954 from mattip/test-extending-cffi
TST. API: test using distributions.h via cffi
Diffstat (limited to 'doc/source/reference/random')
-rw-r--r-- | doc/source/reference/random/examples/cffi.rst | 5 | ||||
-rw-r--r-- | doc/source/reference/random/extending.rst | 20 |
2 files changed, 25 insertions, 0 deletions
diff --git a/doc/source/reference/random/examples/cffi.rst b/doc/source/reference/random/examples/cffi.rst new file mode 100644 index 000000000..04d52203b --- /dev/null +++ b/doc/source/reference/random/examples/cffi.rst @@ -0,0 +1,5 @@ +Extending via CFFI +------------------ + +.. literalinclude:: ../../../../../numpy/random/_examples/cffi/extending.py + :language: python diff --git a/doc/source/reference/random/extending.rst b/doc/source/reference/random/extending.rst index 7b1168c45..3c30e5623 100644 --- a/doc/source/reference/random/extending.rst +++ b/doc/source/reference/random/extending.rst @@ -49,6 +49,25 @@ RNG structure. These functions along with a minimal setup file are included in the `examples` folder, ``numpy.random.examples``. +CFFI +==== + +CFFI can be used to directly access the functions in +``include/numpy/random/distributions.h``. Some "massaging" of the header +file is required: + +.. literalinclude:: ../../../../numpy/random/_examples/cffi/extending.py + :language: python + :end-before: dlopen + +Once the header is parsed by ``ffi.cdef``, the functions can be accessed +directly from the ``_generator`` shared object, using the `BitGenerator.cffi` interface. + +.. literalinclude:: ../../../../numpy/random/_examples/cffi/extending.py + :language: python + :start-after: dlopen + + New Basic RNGs ============== `~Generator` can be used with other user-provided BitGenerators. The simplest @@ -85,3 +104,4 @@ Examples Numba <examples/numba> CFFI + Numba <examples/numba_cffi> Cython <examples/cython/index> + CFFI <examples/cffi> |