JuliaArrays / OffsetArrays.jl

Fortran-like arrays with arbitrary, zero or negative starting indices.
Other
198 stars 40 forks source link

_unsafe_wrap: Allow ind NTuple to have mixed AbstractUnitRanges #296

Closed mkitti closed 2 years ago

mkitti commented 2 years ago

master:

julia> using OffsetArrays

julia> unsafe_wrap(OffsetArray{Int}, Ptr{Int}(Libc.malloc(7*11*8)), -3:3, -5:5);

julia> unsafe_wrap(OffsetArray{Int}, Ptr{Int}(Libc.malloc(7*11*8)), -3:3, Base.OneTo(5));
ERROR: MethodError: no method matching _unsafe_wrap(::Ptr{Int64}, ::Tuple{UnitRange{Int64}, Base.OneTo{Int64}})
Closest candidates are:
  _unsafe_wrap(::Ptr{T}, ::Tuple{Vararg{T, N}} where T; own, kw...) where {T, N} at ~/.julia/dev/OffsetArrays/src/OffsetArrays.jl:629

This pull request

julia> using OffsetArrays

julia> unsafe_wrap(OffsetArray{Int}, Ptr{Int}(Libc.malloc(7*11*8)), -3:3, -5:5);

julia> unsafe_wrap(OffsetArray{Int}, Ptr{Int}(Libc.malloc(7*11*8)), -3:3, Base.OneTo(5));

This normalizes unsafe_wrap to take similar arguments as the constructors.

codecov[bot] commented 2 years ago

Codecov Report

Merging #296 (c82d196) into master (c42fe3d) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #296   +/-   ##
=======================================
  Coverage   96.35%   96.35%           
=======================================
  Files           5        5           
  Lines         439      439           
=======================================
  Hits          423      423           
  Misses         16       16           
Impacted Files Coverage Δ
src/OffsetArrays.jl 98.27% <100.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 c42fe3d...c82d196. Read the comment docs.

jishnub commented 2 years ago

LGTM overall

jishnub commented 2 years ago

Could you also bump the patch version?

mkitti commented 2 years ago

Thanks for the suggestion. Version has been bumped to 1.12.1