Skip to content

Make array ctor template on shape and stride parameters #582

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 1 commit into from
Feb 14, 2017

Conversation

SylvainCorlay
Copy link
Member

I need to be able to initialize arrays with other sequence types than std::vector without copying strides and shape into a vector first.

Copy link
Member

@aldanor aldanor left a comment

Choose a reason for hiding this comment

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

+1 to this, modulo a few minor remarks.

template<typename T> array(const std::vector<size_t>& shape,
const std::vector<size_t>& strides,
template<typename T, typename ST, typename DT>
array(const ST& shape,
Copy link
Member

Choose a reason for hiding this comment

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

Minor: indentation seems off.

@@ -328,8 +328,9 @@ class array : public buffer {

array() : array(0, static_cast<const double *>(nullptr)) {}

array(const pybind11::dtype &dt, const std::vector<size_t> &shape,
const std::vector<size_t> &strides, const void *ptr = nullptr,
template <typename ST, typename DT>
Copy link
Member

Choose a reason for hiding this comment

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

Maybe s/ST/Shape/, s/DT/Strides/ (in other overloads too) so the signatures are a bit less cryptic?

@SylvainCorlay SylvainCorlay force-pushed the template-ctor branch 3 times, most recently from b142c20 to acbcdeb Compare January 1, 2017 22:54
@wjakob
Copy link
Member

wjakob commented Feb 14, 2017

Merged, thanks!

@wjakob wjakob merged commit bee8827 into pybind:master Feb 14, 2017
@dean0x7d
Copy link
Member

I think this PR was WIP. All the CI tests were failing with compiler errors.

dean0x7d added a commit to dean0x7d/pybind11 that referenced this pull request Feb 14, 2017
@dean0x7d dean0x7d mentioned this pull request Feb 14, 2017
wjakob pushed a commit that referenced this pull request Feb 14, 2017
@wjakob
Copy link
Member

wjakob commented Feb 14, 2017

REVERTED -- I (mistakenly) assumed this was ready (it seemed like an innocuous change).

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.

4 participants