Skip to content

Commit

Permalink
Support maximum(Block(OneTo(+∞)) (#211)
Browse files Browse the repository at this point in the history
* maximum

* mention pr
  • Loading branch information
DanielVandH authored Dec 9, 2024
1 parent 854d430 commit 13184d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion 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.15.1"
version = "0.15.2"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
6 changes: 4 additions & 2 deletions ext/InfiniteArraysBlockArraysExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ module InfiniteArraysBlockArraysExt
using InfiniteArrays, BlockArrays
using InfiniteArrays.ArrayLayouts, InfiniteArrays.LazyArrays, InfiniteArrays.LinearAlgebra

import Base: length, size, axes, BroadcastStyle, copy, +, -
import Base: length, size, axes, BroadcastStyle, copy, +, -, maximum, OneTo
import Base.Broadcast: Broadcasted
import ArrayLayouts: sub_materialize, axes_print_matrix_row
import InfiniteArrays: OneToInf, PosInfinity, InfRanges, RealInfinity, Infinity, InfStepRange, TridiagonalToeplitzLayout
import InfiniteArrays: OneToInf, PosInfinity, InfRanges, RealInfinity, Infinity, InfStepRange, TridiagonalToeplitzLayout, InfiniteCardinal
import BlockArrays: AbstractBlockLayout, sizes_from_blocks, BlockTridiagonal, OneToCumsum, BlockSlice, AbstractBlockedUnitRange,
BlockLayout
import LazyArrays: PaddedColumns, LazyArrayStyle
Expand All @@ -28,6 +28,8 @@ BlockArrays.blocklasts(a::InfRanges) = Fill(length(a),1)

BlockArrays.findblock(::BlockedOneTo, ::RealInfinity) = Block(ℵ₀)

maximum(::BlockRange{1, Tuple{OneTo{InfiniteCardinal{0}}}}) = Block(ℵ₀)

function BlockArrays.sortedunion(a::Vcat{Int,1,<:Tuple{Union{Int,AbstractVector{Int}},<:AbstractRange}},
b::Vcat{Int,1,<:Tuple{Union{Int,AbstractVector{Int}},<:AbstractRange}})
@assert a == b # TODO: generailse? Not sure how to do so in a type stable fashion
Expand Down
5 changes: 5 additions & 0 deletions test/test_infblock.jl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ const BlockTriPertToeplitz = InfiniteArraysBlockArraysExt.BlockTriPertToeplitz
@test findblock(blockedrange(1:2:∞), RealInfinity()) == Block(ℵ₀)
end

@testset "maximum of Inf Block Range" begin
# See https://github.com/JuliaApproximation/HarmonicOrthogonalPolynomials.jl/pull/89
@test maximum(Block.(Base.OneTo(Integer(+∞)))) == Block(ℵ₀)
end

@testset "BlockTridiagonal Pert Toeplitz" begin
A = BlockTridiagonal(Vcat([fill(1.0, 2, 1), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2), Matrix(1.0I, 2, 2)], Fill(Matrix(1.0I, 2, 2), ∞)),
Vcat([zeros(1, 1)], Fill(zeros(2, 2), ∞)),
Expand Down

2 comments on commit 13184d6

@dlfivefifty
Copy link
Member

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/121023

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.15.2 -m "<description of version>" 13184d68cfd7d32abcdbf535fc86182a27837aae
git push origin v0.15.2

Please sign in to comment.