Skip to content

Commit 0d004f3

Browse files
authored
Merge pull request #209 from yungyuc/fix-is-contiguous
Fix build error caused by upstream xtensor change (in xtensor master)
2 parents e33ad39 + a956ad8 commit 0d004f3

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/xtensor-python/pycontainer.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ namespace xt
9595
auto& reshape(S&& shape, layout_type layout = base_type::static_layout) &;
9696

9797
layout_type layout() const;
98+
bool is_contiguous() const noexcept;
9899

99100
using base_type::operator();
100101
using base_type::operator[];
@@ -465,6 +466,27 @@ namespace xt
465466
}
466467
}
467468

469+
/**
470+
* Return whether or not the container uses contiguous buffer
471+
* @return Boolean for contiguous buffer
472+
*/
473+
template <class D>
474+
inline bool pycontainer<D>::is_contiguous() const noexcept
475+
{
476+
if (PyArray_CHKFLAGS(python_array(), NPY_ARRAY_C_CONTIGUOUS))
477+
{
478+
return 1 == this->strides().back();
479+
}
480+
else if (PyArray_CHKFLAGS(python_array(), NPY_ARRAY_F_CONTIGUOUS))
481+
{
482+
return 1 == this->strides().front();
483+
}
484+
else
485+
{
486+
return false;
487+
}
488+
}
489+
468490
/**
469491
* Import the numpy Python module.
470492
*/

0 commit comments

Comments
 (0)