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

Origin as a callable to construct OffsetArrays #276

Merged
merged 5 commits into from
May 9, 2022

Conversation

jishnub
Copy link
Member

@jishnub jishnub commented May 8, 2022

Based on the discussion in #274, this changes the behavior of Origin to make shifting the origin of arrays more convenient.

After this, the following work:

julia> using OffsetArrays: Origin

julia> a = [1 2; 3 4]
2×2 Matrix{Int64}:
 1  2
 3  4

julia> b = Origin(0)(a)
2×2 OffsetArray(::Matrix{Int64}, 0:1, 0:1) with eltype Int64 with indices 0:1×0:1:
 1  2
 3  4

julia> Origin(b)(a)
2×2 OffsetArray(::Matrix{Int64}, 0:1, 0:1) with eltype Int64 with indices 0:1×0:1:
 1  2
 3  4

@codecov
Copy link

codecov bot commented May 8, 2022

Codecov Report

Merging #276 (d2905cb) into master (54ade62) will decrease coverage by 0.61%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #276      +/-   ##
==========================================
- Coverage   96.52%   95.90%   -0.62%     
==========================================
  Files           5        5              
  Lines         460      464       +4     
==========================================
+ Hits          444      445       +1     
- Misses         16       19       +3     
Impacted Files Coverage Δ
src/axes.jl 100.00% <ø> (ø)
src/OffsetArrays.jl 97.77% <100.00%> (-0.63%) ⬇️
src/origin.jl 100.00% <100.00%> (ø)
src/utils.jl 96.00% <0.00%> (-2.00%) ⬇️

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 54ade62...d2905cb. Read the comment docs.

Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

I have this in my todo list but was caught by other things. Thank you so much for handling this!

I assume you'll add test later?

src/origin.jl Show resolved Hide resolved
Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

I'm so glad that we've created this useful Origin concept that saves me from the mind-twisting offset calculation trials.

@jishnub jishnub merged commit 4959bab into JuliaArrays:master May 9, 2022
@jishnub jishnub deleted the origin branch May 9, 2022 11:57
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.

2 participants