FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [View Raw Code]   [Original HTTPS Page]

xtensor-python/docs/source/array_tensor.rst at master · Roy-Kid/xtensor-python · GitHub

Repository navigation

Latest commit

 

History

History
27 lines (18 loc) · 1.19 KB
  1. xtensor-python
  2. docs
  3. source

array_tensor.rst

File metadata and controls

27 lines (18 loc) · 1.19 KB

Arrays and tensors

xtensor-python provides two container types wrapping numpy arrays: pyarray and pytensor. They are the counterparts to xarray and xtensor containers.

pyarray

Like xarray, pyarray has a dynamic shape. This means that you can reshape the numpy array on the C++ side and see this change reflected on the python side. pyarray doesn't make a copy of the shape or the strides, but reads them each time it is needed. Therefore, if a reference on a pyarray is kept in the C++ code and the corresponding numpy array is then reshaped in the python code, this modification will reflect in the pyarray.

pytensor

Like xtensor, pytensor has a static stack-allocated shape. This means that the shape of the numpy array is copied into the shape of the pytensor upon creation. As a consequence, reshapes are not reflected across languages. However, this drawback is offset by a more effective computation of shape and broadcast.


Back | FazBrowse Home | New Git URL