Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 9, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions include/xtensor-python/pycontainer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ namespace xt
void reshape(S&& shape, layout_type layout = base_type::static_layout);

layout_type layout() const;
bool is_contiguous() const noexcept;

using base_type::operator();
using base_type::operator[];
Expand Down Expand Up @@ -442,6 +443,27 @@ namespace xt
}
}

/**
* Return whether or not the container uses contiguous buffer
* @return Boolean for contiguous buffer
*/
template <class D>
inline bool pycontainer<D>::is_contiguous() const noexcept
{
if (PyArray_CHKFLAGS(python_array(), NPY_ARRAY_C_CONTIGUOUS))
{
return 1 == this->strides().back();
Copy link
Contributor Author

@yungyuc yungyuc Oct 9, 2019

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.

}
else if (PyArray_CHKFLAGS(python_array(), NPY_ARRAY_F_CONTIGUOUS))
{
return 1 == this->strides().front();
}
else
{
return false;
}
}

/**
* Import the numpy Python module.
*/
Expand Down