• Jason Rhinelander's avatar
    Accept abitrary containers and iterators for shape/strides · 5f383862
    Jason Rhinelander authored
    This adds support for constructing `buffer_info` and `array`s using
    arbitrary containers or iterator pairs instead of requiring a vector.
    
    This is primarily needed by PR #782 (which makes strides signed to
    properly support negative strides, and will likely also make shape and
    itemsize to avoid mixed integer issues), but also needs to preserve
    backwards compatibility with 2.1 and earlier which accepts the strides
    parameter as a vector of size_t's.
    
    Rather than adding nearly duplicate constructors for each stride-taking
    constructor, it seems nicer to simply allow any type of container (or
    iterator pairs).  This works by replacing the existing vector arguments
    with a new `detail::any_container` class that handles implicit
    conversion of arbitrary containers into a vector of the desired type.
    It can also be explicitly instantiated with a pair of iterators (e.g.
    by passing {begin, end} instead of the container).
    5f383862
test_numpy_array.cpp 10.5 KB