package pyml

  1. Overview
  2. Docs
OCaml bindings for Python

Install

Dune Dependency

Authors

Maintainers

Sources

20210924.tar.gz
sha512=c1e979751ef933635ae6d7f69e1638a3accfd082b0b3a364c4305eb268a67f73af26e321beef4cf3b99ab2fe35ab642c03b005ad620b0268e22b4a09b6f7c1c0

doc/pyml/Numpy/index.html

Module NumpySource

OCaml Interface for Numpy.

Arrays are passed in place (without copy): Python and OCaml programs can change the contents of the array and the changes are visible in the other language.

The following table gives the correspondence between bigarray kinds and Numpy element types.

  • float32 / NPY_FLOAT
  • float64 / NPY_DOUBLE
  • int8_signed / NPY_BYTE
  • int8_unsigned / NPY_UBYTE
  • int16_signed / NPY_SHORT
  • int16_unsigned / NPY_USHORT
  • int32 / NPY_INT
  • int64 / NPY_LONGLONG
  • nativeint / NPY_LONG
  • complex32 / NPY_CFLOAT
  • complex64 / NPY_CDOUBLE
  • char / NPY_CHAR

Other kinds/element types are not supported. In particular, OCaml integer kind, int, has no equivalent type in Numpy.

Sourceval of_bigarray : ('a, 'b, 'c) Bigarray.Genarray.t -> Py.Object.t

of_bigarray a returns a Numpy array that shares the same contents than the OCaml array a.

Sourceval to_bigarray : ('a, 'b) Bigarray.kind -> 'c Bigarray.layout -> Py.Object.t -> ('a, 'b, 'c) Bigarray.Genarray.t

to_bigarray kind layout a returns a bigarray that shares the same contents than the Numpy array a.

OCaml

Innovation. Community. Security.