Skip to content

type assertion in convert#312

Open
jishnub wants to merge 2 commits intoJuliaArrays:masterfrom
jishnub:strictconvert
Open

type assertion in convert#312
jishnub wants to merge 2 commits intoJuliaArrays:masterfrom
jishnub:strictconvert

Conversation

@jishnub
Copy link
Copy Markdown
Member

@jishnub jishnub commented Oct 14, 2022

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.

@jishnub jishnub requested a review from johnnychen94 October 14, 2022 09:57
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 14, 2022

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%> (ø)

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

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.

1 participant