xtensor-stack / xtensor-python

Python bindings for xtensor
BSD 3-Clause "New" or "Revised" License
347 stars 58 forks source link

Compatibility between xt::pytensor and xt::xtensor #112

Closed yoshipon closed 7 years ago

yoshipon commented 7 years ago

Thank you for developing xtensor and xtensor-python, which are very practical libraries. In some cases, I want to write the following functions and export to Python with pybind11:

void foo(const xt::pytensor<double, 1> &a)
{
  xt::xtensor<double, 1> b = 0.5 * a;
}

This function can be compiled with g++ (5.4.0@ubuntu 16.04). However, the following Python code stops with Segmentation Fault (core dumped): foo(np.array([1])) although this code works correctly: foo(np.array([1,2,3]))

If you have some ideas about this bug and don't have enough time for debugging, I would like to try fixing according to your comments.

JohanMabille commented 7 years ago

Thank you for reporting! Which version of xtensor and xtensor-python do you use ?

yoshipon commented 7 years ago

Thank you for your reply.

I am using latest version of them. I cloned their git repositories just few minutes ago and installed with cmake.

JohanMabille commented 7 years ago

Ok, it seems the bug is in xtensor. I can reproduce it with the following code:

xt::xtensor<int, 1> a = { 1 };
xt::xtensor<int, 1> res = 2 * a;

I'm working on a fix.

JohanMabille commented 7 years ago

@yoshipon the bug has been fixed in xtensor master. Can you confirm it works for you ?

yoshipon commented 7 years ago

@JohanMabille Thank you very much for your super-fast response. I confirmed that now the problem is fixed.

JohanMabille commented 7 years ago

you're welcome!

SylvainCorlay commented 7 years ago

@yoshipon we have made a patch release of xtensor with this bugfix.

xtensor 0.11.3.

The conda recipe is building on conda forge.

SylvainCorlay commented 7 years ago

I cloned their git repositories just few minutes ago and installed with cmake.

Cool!

If you are working with other xtensor projects such as xtensor-python, we recommend using the latest the latest tagged version in general.

Also, we have a fairly active chat room here: https://gitter.im/QuantStack/Lobby !

yoshipon commented 7 years ago

@SylvainCorlay Thank you for informing about them!