Vexatos / CircularArrays.jl

Multi-dimensional arrays with fixed size and circular indexing.
MIT License
38 stars 12 forks source link

No constructor for fully specified type #17

Closed Wizarth closed 2 years ago

Wizarth commented 2 years ago

These all produce the same type: CircularArray{Float64, 2, Matrix{Float64}}

However, CircularArray{Float64, 2, Matrix{Float64}}( zeros(2, 2) ) fails with MethodError: no method matching CircularArray{Float64, 2, Matrix{Float64}}(::Matrix{Float64})

This is a problem when creating a function that takes an AbstractArray, produces a new Vector that gets reshaped to the same size as the AbstractArray, then tries to return the same type as the original AbstractArray using convert, or by trying to call the constructor using typeofor by the function being parametric.

I think the missing constructor can be addressed by adding a constructor that is parametric on all three types? I don't know if it makes sense to have convert work in this context.

Vexatos commented 2 years ago

It was indeed just missing another constructor. Thanks for the report.