JuliaArrays / OffsetArrays.jl

Fortran-like arrays with arbitrary, zero or negative starting indices.
Other
195 stars 40 forks source link

type assertion in convert #312

Open jishnub opened 1 year ago

jishnub commented 1 year ago

Since something similar is implemented on Julia nightly now, it seems to be the preferred way forward. After this, the following is inferred:

julia> @inferred (x -> convert(OffsetArray{Float64,2,Matrix{Float64}}, x[1]))(Any[zeros(1,1)])
1×1 OffsetArray(::Matrix{Float64}, 1:1, 1:1) with eltype Float64 with indices 1:1×1:1:
 0.0

This may help with inference downstream. Mildly breaking if T(x) doesn't return an object of type T, but then the conversion fails anyway, so this may be considered a bug. It's better to error if the conversion fails.

codecov[bot] commented 1 year ago

Codecov Report

Merging #312 (88073a4) into master (9c3b73f) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #312   +/-   ##
=======================================
  Coverage   96.45%   96.45%           
=======================================
  Files           5        5           
  Lines         451      451           
=======================================
  Hits          435      435           
  Misses         16       16           
Impacted Files Coverage Δ
src/OffsetArrays.jl 98.29% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more