Skip to content

type assertion in convert#312

Open
jishnub wants to merge 2 commits into
JuliaArrays:masterfrom
jishnub:strictconvert
Open

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

Conversation

@jishnub

@jishnub jishnub commented Oct 14, 2022

Copy link
Copy Markdown
Member

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

codecov Bot commented Oct 14, 2022

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.45%. Comparing base (9c3b73f) to head (88073a4).
⚠️ Report is 46 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #312   +/-   ##
=======================================
  Coverage   96.45%   96.45%           
=======================================
  Files           5        5           
  Lines         451      451           
=======================================
  Hits          435      435           
  Misses         16       16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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