Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

type assertion in convert #312

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jishnub
Copy link
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.

@codecov
Copy link

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