Skip to content

Fix build error caused by upstream xtensor change (in xtensor master) - #209

Merged
JohanMabille merged 2 commits into
xtensor-stack:masterfrom
yungyuc:fix-is-contiguous
Dec 9, 2019
Merged

JohanMabille merged 2 commits into
xtensor-stack:masterfrom
yungyuc:fix-is-contiguous

Conversation

@yungyuc

@yungyuc yungyuc commented Oct 4, 2019

Copy link
Copy Markdown
Contributor

The upstream change broke the build: xtensor-stack/xtensor@da7de15

Add pycontainer::is_contiguous to make xtensor happy.

The upstream change broke the build: xtensor-stack/xtensor@da7de15

Add pycontainer::is_contiguous to make xtensor happy.
@yungyuc

yungyuc commented Oct 9, 2019

Copy link
Copy Markdown
Contributor Author

Hello, I wonder if anyone has time to take a look at the fix?

@JohanMabille

Copy link
Copy Markdown
Member

Hi,

Sorry for the late reply. I think you also need to check that the first (if column_major) or last (if row_major) stride is 1, because we can have dynamic row_major layout for a view taking one element out of two for instance.

For row-major (c contiguous), make sure the last stride is unity. For colunm-major (fortran contiguous), make sure the first stride is unity.
{
if (PyArray_CHKFLAGS(python_array(), NPY_ARRAY_C_CONTIGUOUS))
{
return 1 == this->strides().back();

@yungyuc yungyuc Oct 9, 2019 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this->strides() cannot be empty, and the element cannot be 0.

@yungyuc

yungyuc commented Oct 9, 2019

Copy link
Copy Markdown
Contributor Author

@JohanMabille thanks a lot for the comments (it's not at all late). I am not yet familiar with the xtensor/xtensor-python API, so this hot fix is far from comprehensive. Your help is very much needed.

@yungyuc

yungyuc commented Oct 16, 2019

Copy link
Copy Markdown
Contributor Author

@JohanMabille Is there something that I can improve in the PR?

@JohanMabille

Copy link
Copy Markdown
Member

I think the strides should not be considered as non empty.
Adding a test that passes a 0D array to a function expecting a pyarray object could confirm that.

@JohanMabille
JohanMabille merged commit 0d004f3 into xtensor-stack:master Dec 9, 2019
@yungyuc yungyuc mentioned this pull request Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants