Skip to content

Commit

Permalink
LazyArrays v2.0 support (#174)
Browse files Browse the repository at this point in the history
* Support LazyArrays v2.0

* add block array tests

* Update Project.toml

* Fix padded

* ambiguity with sublayout of ApplyBandedLayout

* Julia v1.10 restriction

* Revert "ambiguity with sublayout of ApplyBandedLayout"

This reverts commit 31038e9.

* add tests

* Update Project.toml
  • Loading branch information
dlfivefifty authored May 21, 2024
1 parent 99d9671 commit 0049f1b
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 16 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1'
- '1.10'
os:
- ubuntu-latest
- macOS-latest
Expand Down
14 changes: 7 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "InfiniteArrays"
uuid = "4858937d-0d70-526a-a4dd-2d5cb5dd786c"
version = "0.13.8"
version = "0.14"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand All @@ -14,18 +14,18 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
[compat]
Aqua = "0.8"
ArrayLayouts = "1.8"
BandedMatrices = "0.17.18, 1.0"
BandedMatrices = "1.0"
BlockArrays = "1.0"
Base64 = "1"
DSP = "0.7"
FillArrays = "1.0"
Infinities = "0.1.1"
LazyArrays = "1.0"
LazyBandedMatrices = "0.8.9, 0.9"
LazyArrays = "2.0.2"
LinearAlgebra = "1.6"
SparseArrays = "1"
Statistics = "1"
Test = "1"
julia = "1.6"
julia = "1.10"

[extensions]
InfiniteArraysDSPExt = "DSP"
Expand All @@ -35,14 +35,14 @@ InfiniteArraysStatisticsExt = "Statistics"
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
BlockArrays = "8e7c35d0-a365-5155-bbbb-fb81a777f24e"
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Aqua", "Test", "BandedMatrices", "LazyBandedMatrices", "Statistics", "SparseArrays", "Base64", "DSP"]
test = ["Aqua", "Test", "BandedMatrices", "BlockArrays", "Statistics", "SparseArrays", "Base64", "DSP"]

[weakdeps]
DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2"
Expand Down
4 changes: 3 additions & 1 deletion src/InfiniteArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ import FillArrays: AbstractFill, Eye, Fill, Ones, RectDiagonal, Zeros, fill_resh
import Infinities: InfiniteCardinal, Infinity, ∞

import LazyArrays: AbstractCachedVector, ApplyLayout, CachedArray, CachedVector, InvColumnLayout,
LazyArrayStyle, LazyLayout, LazyMatrix, PaddedLayout, _padded_sub_materialize, sub_paddeddata
LazyArrayStyle, LazyLayout, LazyMatrix, PaddedColumns, _padded_sub_materialize, sub_paddeddata

import LinearAlgebra: AdjOrTrans, HermOrSym, diag, norm, norm1, norm2, normp

import LazyArrays: AbstractPaddedLayout

export ∞, ℵ₀, Hcat, Vcat, Zeros, Ones, Fill, Eye, BroadcastArray, cache
import Base: unitrange, oneto

Expand Down
10 changes: 5 additions & 5 deletions src/infarrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,15 +295,15 @@ sub_materialize(::AbstractBandedLayout, V, ::Tuple{InfAxes,OneTo{Int}}) = V
##

sublayout(::DiagonalLayout{L}, ::Type{<:Tuple{KR,Integer}}) where {L,KR<:InfAxes} =
sublayout(PaddedLayout{UnknownLayout}(), Tuple{KR})
sublayout(PaddedColumns{UnknownLayout}(), Tuple{KR})
sublayout(::DiagonalLayout{L}, ::Type{<:Tuple{Integer,JR}}) where {L,JR<:InfAxes} =
sublayout(PaddedLayout{UnknownLayout}(), Tuple{JR})
sublayout(PaddedColumns{UnknownLayout}(), Tuple{JR})
-

sublayout(::AbstractBandedLayout, ::Type{<:Tuple{KR,Integer}}) where {KR<:InfAxes} =
sublayout(PaddedLayout{UnknownLayout}(), Tuple{KR})
sublayout(PaddedColumns{UnknownLayout}(), Tuple{KR})
sublayout(::AbstractBandedLayout, ::Type{<:Tuple{Integer,JR}}) where {JR<:InfAxes} =
sublayout(PaddedLayout{UnknownLayout}(), Tuple{JR})
sublayout(PaddedColumns{UnknownLayout}(), Tuple{JR})


function sub_paddeddata(::AbstractBandedLayout, S::SubArray{T,1,<:AbstractMatrix,<:Tuple{InfAxes,Integer}}) where T
Expand Down Expand Up @@ -393,7 +393,7 @@ sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{<:Any,In
sub_materialize(::ApplyLayout{typeof(hcat)}, V::AbstractMatrix, ::Tuple{InfAxes,Any}) = ApplyArray(V)


sub_materialize(::PaddedLayout, v::AbstractVector{T}, ::Tuple{InfAxes}) where T =
sub_materialize(::AbstractPaddedLayout, v::AbstractVector{T}, ::Tuple{InfAxes}) where T =
_padded_sub_materialize(v)

sub_materialize(lay::InvColumnLayout, v::AbstractVector, ax::Tuple{InfAxes}) =
Expand Down
11 changes: 10 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using LinearAlgebra, SparseArrays, InfiniteArrays, Infinities, FillArrays, LazyArrays, Statistics, Test, Base64
using BandedMatrices, LazyBandedMatrices
using BandedMatrices
import InfiniteArrays: InfUnitRange, InfStepRange, OneToInf, NotANumber, oneto, unitrange
import LazyArrays: CachedArray, MemoryLayout, LazyLayout, DiagonalLayout, LazyArrayStyle, colsupport, DualLayout
import BandedMatrices: _BandedMatrix, BandedColumns
Expand Down Expand Up @@ -1208,4 +1208,13 @@ end
@inferred Val((D -> diag(D,1))(D))
end

@testset "inf padded" begin
v = Vcat(1, Zeros(∞))
@test LazyArrays.sub_materialize(view(v, 1:∞))[1:10] == [1; zeros(9)]
@test LazyArrays.sub_materialize(view(v, 2:∞))[1:10] == zeros(10)
@test v[2:∞] isa Zeros
@test v[1:∞] == v
end

include("test_infconv.jl")
include("test_block.jl")
10 changes: 10 additions & 0 deletions test/test_block.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using InfiniteArrays, BlockArrays
using InfiniteArrays: OneToInf

@testset "blockedonetoinf" begin
b = blockedrange(OneToInf())
b2 = b .+ b;
for i in 1:10
@test b2[Block(i)] == b[Block(i)] + b[Block(i)]
end
end

2 comments on commit 0049f1b

@dlfivefifty
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/107288

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.14.0 -m "<description of version>" 0049f1b9bf16bd521f12bfb4f687f256a11b339d
git push origin v0.14.0

Please sign in to comment.