Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
27 lines (18 loc) · 1.19 KB

File metadata and controls

27 lines (18 loc) · 1.19 KB
Copy raw file
Download raw file
Outline
Edit and raw actions

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.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.