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

similar does not accept colons as indices #126

Merged
merged 3 commits into from
Jul 24, 2020

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented Jul 8, 2020

This attempts to get around #122 by explicitly preventing colons being passed to similar. This means that the StackOverflowError now becomes a MethodError

julia> oa = OffsetArray(rand(3,3), 0:2, 0:2)
3×3 OffsetArray(::Array{Float64,2}, 0:2, 0:2) with eltype Float64 with indices 0:2×0:2:
 0.339644  0.584673  0.474432
 0.689602  0.65758   0.673912
 0.920069  0.360913  0.917047

julia> similar(oa, Float64, (:,:))
ERROR: MethodError: no method matching similar(::OffsetArray{Float64,2,Array{Float64,2}}, ::Type{Float64}, ::Tuple{Colon,Colon})

@codecov
Copy link

codecov bot commented Jul 8, 2020

Codecov Report

Merging #126 into master will decrease coverage by 1.71%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #126      +/-   ##
==========================================
- Coverage   86.17%   84.45%   -1.72%     
==========================================
  Files           2        2              
  Lines         188      193       +5     
==========================================
+ Hits          162      163       +1     
- Misses         26       30       +4     
Impacted Files Coverage Δ
src/OffsetArrays.jl 86.84% <ø> (-2.28%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2ce0104...c33e94a. Read the comment docs.

@johnnychen94 johnnychen94 requested a review from timholy July 8, 2020 11:02
Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This is a good fix. Just needs a test.

FYI, motivated partly by #87 I've begun to rethink Julia's similar dispatch chain. That's delicate work because we can't break compatibility, and I ran short on time before I could finish that. But my preliminary guess is that ultimately we'll need to delete more types from those accepted by this similar method.

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.

3 participants