Skip to content

Warning on strides(a::AbstractArray) when plotting array reshaped from stridden subvector #391

@wsshin

Description

@wsshin

I get a warning when using pcolor on a matrix generated by reshape on a stridden subvector. For example,

using PyPlot
a = rand(10);
b = @view a[1:3:end];  # stridden subvector
c = reshape(b, 2, :);  # reshape subvector into matrix
pcolor(c)

produces the following warning:

┌ Warning: The default `strides(a::AbstractArray)` implementation is deprecated for general arrays.
│ Specialize `strides(::Base.ReshapedArray)` if `Base.ReshapedArray` indeed uses a strided representation in memory.
│ Warning: inappropriately implementing this method for an array type that does not use strided
│ storage may lead to incorrect results or segfaults.
│   caller = ip:0x0
└ @ Core :-1
┌ Warning: The default `strides(a::AbstractArray)` implementation is deprecated for general arrays.
│ Specialize `strides(::Base.ReshapedArray)` if `Base.ReshapedArray` indeed uses a strided representation in memory.
│ Warning: inappropriately implementing this method for an array type that does not use strided
│ storage may lead to incorrect results or segfaults.
│   caller = stride at abstractarray.jl:350 [inlined]
└ @ Core ./abstractarray.jl:350

If a matrix itself is stridden (instead of a vector being stridden and reshaped into a matrix), then the warning does not occur.

Here is the version information:

julia> VERSION
v"0.7.1-pre.0"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions