Skip to content

Commit c9248e0

Browse files
authored
Update for Julia v1.7 (#77)
* Update for Julia v1.7 * Update indices.jl
1 parent 3eb6cf5 commit c9248e0

File tree

9 files changed

+18
-31
lines changed

9 files changed

+18
-31
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ jobs:
1111
matrix:
1212
version:
1313
- '1.6'
14+
- '^1.7.0-0'
1415
os:
1516
- ubuntu-latest
1617
- macOS-latest

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "QuasiArrays"
22
uuid = "c4ea9172-b204-11e9-377d-29865faadc5c"
33
authors = ["Sheehan Olver <solver@mac.com>"]
4-
version = "0.7.1"
4+
version = "0.8.0"
55

66
[deps]
77
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/QuasiArrays.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import Base: getindex, size, axes, axes1, length, ==, isequal, iterate, Cartesia
77
import Base: @_inline_meta, DimOrInd, OneTo, @_propagate_inbounds_meta, @_noinline_meta,
88
DimsInteger, error_if_canonical_getindex, @propagate_inbounds, _return_type,
99
_maybetail, tail, _getindex, _maybe_reshape, index_ndims, _unsafe_getindex,
10-
index_shape, to_shape, unsafe_length, @nloops, @ncall, unalias, _unaliascopy,
10+
index_shape, to_shape, @nloops, @ncall, unalias, _unaliascopy,
1111
to_index, to_indices, _to_subscript_indices, _splatmap, dataids,
1212
compute_stride1, compute_offset1, fill_to_length
1313
import Base: Slice, IdentityUnitRange, ScalarIndex, RangeIndex, view, viewindexing, mightalias, ensure_indexable, index_dimsum,
14-
check_parent_index_match, reindex, _isdisjoint, unsafe_indices, _unsafe_ind2sub,
14+
check_parent_index_match, reindex, _isdisjoint, _unsafe_ind2sub,
1515
_ind2sub, _sub2ind, _ind2sub_recurse, _lookup, SubArray,
1616
parentindices, reverse, ndims, checkbounds, uncolon,
1717
maybeview, unsafe_view, checkindex, checkbounds_indices,

src/indices.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,17 @@ copy(d::Inclusion) = d
166166
domain(A::Inclusion) = A.domain
167167
domain(A::AbstractUnitRange) = A
168168
axes(S::Inclusion) = (S,)
169-
unsafe_indices(S::Inclusion) = (S,)
170169
axes1(S::Inclusion) = S
171170
axes(S::Inclusion{<:Any,<:OneTo}) = (S.domain,)
172-
unsafe_indices(S::Inclusion{<:Any,<:OneTo}) = (S.domain,)
173171
axes1(S::Inclusion{<:Any,<:OneTo}) = S.domain
174172

175173
first(S::Inclusion) = first(S.domain)
176174
last(S::Inclusion) = last(S.domain)
177175
size(S::Inclusion) = (cardinality(S.domain),)
178176
length(S::Inclusion) = cardinality(S.domain)
179-
unsafe_length(S::Inclusion) = cardinality(S.domain)
177+
if VERSION < v"1.7-"
178+
Base.unsafe_length(S::Inclusion) = length(S)
179+
end
180180
cardinality(S::Inclusion) = cardinality(S.domain)
181181
measure(x) = cardinality(x) # TODO: Inclusion(0:0.5:1) should have
182182
getindex(S::Inclusion{T}, i::T) where T = (@_inline_meta; @boundscheck checkbounds(S, i); convert(T,i))

src/quasiadjtrans.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,9 @@
99
# user-defined such objects. so do not restrict the wrapped type.
1010
struct QuasiAdjoint{T,S} <: AbstractQuasiMatrix{T}
1111
parent::S
12-
function QuasiAdjoint{T,S}(A::S) where {T,S}
13-
checkeltype_adjoint(T, eltype(A))
14-
new(A)
15-
end
1612
end
1713
struct QuasiTranspose{T,S} <: AbstractQuasiMatrix{T}
1814
parent::S
19-
function QuasiTranspose{T,S}(A::S) where {T,S}
20-
checkeltype_transpose(T, eltype(A))
21-
new(A)
22-
end
2315
end
2416

2517
# basic outer constructors

src/quasibroadcast.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ instantiate(bc::Broadcasted{<:AbstractQuasiArrayStyle{0}}) = bc
100100
result_join(::AbstractQuasiArrayStyle, ::AbstractQuasiArrayStyle, ::Unknown, ::Unknown) =
101101
QuasiArrayConflict()
102102

103-
Base.@propagate_inbounds _newindex(ax::Tuple, I::Tuple) = (Base.unsafe_length(ax[1])==1 ? first(ax[1]) : I[1], _newindex(tail(ax), tail(I))...)
103+
Base.@propagate_inbounds _newindex(ax::Tuple, I::Tuple) = (length(ax[1])==1 ? first(ax[1]) : I[1], _newindex(tail(ax), tail(I))...)
104104
Base.@propagate_inbounds _newindex(ax::Tuple{}, I::Tuple) = ()
105105
Base.@propagate_inbounds _newindex(ax::Tuple, I::Tuple{}) = (first(ax[1]), _newindex(tail(ax), ())...)
106106
Base.@propagate_inbounds _newindex(ax::Tuple{}, I::Tuple{}) = ()

src/subquasiarray.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,11 @@ _quasi_indices_sub(axs::Tuple{AbstractVector{IND},Vararg{Any}}, inds::Tuple{IND,
194194
_quasi_indices_sub(::Tuple{}, ::Tuple{}) = ()
195195
function _quasi_indices_sub(axs::Tuple{AbstractQuasiVector{IND},Vararg{Any}}, inds::Tuple{AbstractArray{IND},Vararg{Any}}) where IND
196196
@_inline_meta
197-
(unsafe_indices(inds[1])..., _quasi_indices_sub(tail(axs), tail(inds))...)
197+
(axes(inds[1])..., _quasi_indices_sub(tail(axs), tail(inds))...)
198198
end
199199
function _quasi_indices_sub(axs::Tuple{AbstractVector{IND},Vararg{Any}}, inds::Tuple{AbstractArray{IND},Vararg{Any}}) where IND
200200
@_inline_meta
201-
(unsafe_indices(inds[1])..., _quasi_indices_sub(tail(axs), tail(inds))...)
201+
(axes(inds[1])..., _quasi_indices_sub(tail(axs), tail(inds))...)
202202
end
203203

204204
quasi_reindex(axs::Tuple{AbstractQuasiOrVector{IND}, Vararg{Any}}, idxs::Tuple{IND, Vararg{Any}}, subidxs::Tuple{Vararg{Any}}) where IND =
@@ -275,12 +275,12 @@ end
275275
function compute_linindex(f, s, IP::Tuple, I::Tuple{ScalarIndex, Vararg{Any}})
276276
@_inline_meta
277277
Δi = I[1]-first(IP[1])
278-
compute_linindex(f + Δi*s, s*unsafe_length(IP[1]), tail(IP), tail(I))
278+
compute_linindex(f + Δi*s, s*length(IP[1]), tail(IP), tail(I))
279279
end
280280
function compute_linindex(f, s, IP::Tuple, I::Tuple{Any, Vararg{Any}})
281281
@_inline_meta
282282
Δi = first(I[1])-first(IP[1])
283-
compute_linindex(f + Δi*s, s*unsafe_length(IP[1]), tail(IP), tail(I))
283+
compute_linindex(f + Δi*s, s*length(IP[1]), tail(IP), tail(I))
284284
end
285285
compute_linindex(f, s, IP::Tuple, I::Tuple{}) = f
286286

@@ -307,7 +307,7 @@ _indices_sub(S::SubQuasiArray) = ()
307307
_indices_sub(S::SubQuasiArray, ::Number, I...) = (@_inline_meta; _indices_sub(S, I...))
308308
function _indices_sub(S::SubQuasiArray, i1::Union{AbstractQuasiArray,AbstractArray}, I...)
309309
@_inline_meta
310-
(unsafe_indices(i1)..., _indices_sub(S, I...)...)
310+
(axes(i1)..., _indices_sub(S, I...)...)
311311
end
312312

313313
@propagate_inbounds maybeview(A::AbstractQuasiArray, args...) = view(A, args...)

test/test_quasiadjtrans.jl

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,6 @@ import QuasiArrays: MemoryLayout
88
@testset "QuasiAdjoint/Transpose" begin
99
@testset "Adjoint and Transpose inner constructor basics" begin
1010
intvec, intmat = QuasiVector([1, 2],0:0.5:0.5), QuasiArray([1 2; 3 4],(0:0.5:0.5,0:0.5:0.5))
11-
# Adjoint/Transpose eltype must match the type of the Adjoint/Transpose of the input eltype
12-
@test_throws ErrorException QuasiAdjoint{Float64,typeof(intvec)}(intvec)
13-
@test_throws ErrorException QuasiAdjoint{Float64,typeof(intmat)}(intmat)
14-
@test_throws ErrorException QuasiTranspose{Float64,typeof(intvec)}(intvec)
15-
@test_throws ErrorException QuasiTranspose{Float64,typeof(intmat)}(intmat)
16-
# Adjoint/Transpose wrapped array type must match the input array type
17-
@test_throws MethodError QuasiAdjoint{Int,Vector{Float64}}(intvec)
18-
@test_throws MethodError QuasiAdjoint{Int,Matrix{Float64}}(intmat)
19-
@test_throws MethodError QuasiTranspose{Int,Vector{Float64}}(intvec)
20-
@test_throws MethodError QuasiTranspose{Int,Matrix{Float64}}(intmat)
2111
# Adjoint/Transpose inner constructor basic functionality, concrete scalar eltype
2212
@test (QuasiAdjoint{Int,typeof(intvec)}(intvec)::QuasiAdjoint{Int,typeof(intvec)}).parent === intvec
2313
@test (QuasiAdjoint{Int,typeof(intmat)}(intmat)::QuasiAdjoint{Int,typeof(intmat)}).parent === intmat

test/test_quasisubarray.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,11 @@ using QuasiArrays, Base64, Test
300300
@testset "Show" begin
301301
a = QuasiVector(randn(3), 0:0.5:1)
302302
v = view(a, :)
303-
@test stringmime("text/plain", v) == "view(QuasiVector{Float64, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}}}, Inclusion(0.0:0.5:1.0)) with eltype Float64"
303+
if VERSION < v"1.7-"
304+
@test stringmime("text/plain", v) == "view(QuasiVector{Float64, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}}}}, Inclusion(0.0:0.5:1.0)) with eltype Float64"
305+
else
306+
@test stringmime("text/plain", v) == "view(QuasiVector{Float64, Tuple{StepRangeLen{Float64, Base.TwicePrecision{Float64}, Base.TwicePrecision{Float64}, $Int}}}, Inclusion(0.0:0.5:1.0)) with eltype Float64"
307+
end
304308
end
305309

306310
@testset "==" begin

0 commit comments

Comments
 (0)