View all files | ||||
Python bindings for the xtensor C++ multi-dimensional array library.
xtensor is a C++ library for multi-dimensional arrays enabling numpy-style broadcasting and lazy computing.
xtensor-python enables inplace use of numpy arrays in C++ with all the benefits from xtensor
The Python bindings for xtensor are based on the pybind11 C++ library, which enables seamless interoperability between C++ and Python.
xtensor-python is a header-only library. We provide a package for the mamba (or conda) package manager.
To get started with using xtensor-python, check out the full documentation
http://xtensor-python.readthedocs.io/
xtensor-python offers two container types wrapping numpy arrays inplace to provide an xtensor semantics
Both containers enable the numpy-style APIs of xtensor (see the numpy to xtensor cheat sheet).
On the one hand, pyarray has a dynamic number of dimensions. Just like numpy arrays, it can be reshaped with a shape of a different length (and the new shape is reflected on the python side).
On the other hand pytensor has a compile time number of dimensions, specified with a template parameter. Shapes of pytensor instances are stack allocated, making pytensor a significantly faster expression than pyarray.
C++ code
Python Code
Outputs
Working example
Get the working example here:
C++ code
Python Code
Outputs
We provide a package for the conda package manager.
This will pull the dependencies to xtensor-python, that is pybind11 and xtensor.
A template for a project making use of xtensor-python is available in the form of a cookiecutter here.
This project is meant to help library authors get started with the xtensor python bindings.
It produces a project following the best practices for the packaging and distribution of Python extensions based on xtensor-python, including a setup.py file and a conda recipe.
Testing xtensor-python requires pytest
To pick up changes in xtensor-python while rebuilding, delete the build/ directory.
xtensor-python's documentation is built with three tools
While doxygen must be installed separately, you can install breathe by typing
Breathe can also be installed with conda
Finally, build the documentation with
from the docs subdirectory.
xtensor-python depends on the xtensor and pybind11 libraries
| master | ^0.26.0 | >=2.6.1,<4 |
| 0.28.0 | ^0.26.0 | >=2.6.1,<3 |
| 0.27.0 | ^0.25.0 | >=2.6.1,<3 |
| 0.26.1 | ^0.24.0 | ~2.4.3 |
| 0.26.0 | ^0.24.0 | ~2.4.3 |
| 0.25.3 | ^0.23.0 | ~2.4.3 |
| 0.25.2 | ^0.23.0 | ~2.4.3 |
| 0.25.1 | ^0.23.0 | ~2.4.3 |
| 0.25.0 | ^0.23.0 | ~2.4.3 |
| 0.24.1 | ^0.21.2 | ~2.4.3 |
| 0.24.0 | ^0.21.1 | ~2.4.3 |
These dependencies are automatically resolved when using the conda package manager.
We use a shared copyright model that enables all contributors to maintain the copyright on their contributions.
This software is licensed under the BSD-3-Clause license. See the LICENSE file for details.