Skip to content

Commit

Permalink
Fix ambiguities for isless with RealInfinity, Infinity, and InfiniteC… (
Browse files Browse the repository at this point in the history
#51)

* Fix ambiguities for isless with RealInfinity, Infinity, and InfiniteCardinality

* Update cardinality.jl
  • Loading branch information
dlfivefifty authored Dec 8, 2023
1 parent 75c14ae commit 8580d78
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Infinities"
uuid = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
authors = ["Sheehan Olver <[email protected]>"]
version = "0.1.7"
version = "0.1.8"

[compat]
Aqua = "0.8"
Expand Down
3 changes: 2 additions & 1 deletion src/Infinities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,8 @@ end
<(s::RealInfinity, ::Infinity) = signbit(s)
<(::Infinity, ::RealInfinity) = false


isless(x::RealInfinity, ::Infinity) = isless(x, RealInfinity())
isless(::Infinity, x::RealInfinity) = isless(RealInfinity(), x)


function -(::Infinity, y::RealInfinity)
Expand Down
8 changes: 8 additions & 0 deletions src/cardinality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ isless(x::AbstractFloat, ::InfiniteCardinal{0}) = isfinite(x)
isless(x::AbstractFloat, ::InfiniteCardinal) = true
isless(::InfiniteCardinal, y::Real) = false
isless(x::InfiniteCardinal, y::AbstractFloat) = false
isless(x::RealInfinity, ::InfiniteCardinal{0}) = isless(x, ∞)
isless(::InfiniteCardinal{0}, x::RealInfinity) = isless(∞, x)
isless(x::RealInfinity, ::InfiniteCardinal) = true
isless(::InfiniteCardinal, x::RealInfinity) = false
isless(x::Infinity, ::InfiniteCardinal{0}) = isless(x, ∞)
isless(::InfiniteCardinal{0}, x::Infinity) = isless(∞, x)
isless(x::Infinity, ::InfiniteCardinal) = true
isless(::InfiniteCardinal, x::Infinity) = false

@generated <(::InfiniteCardinal{N}, ::InfiniteCardinal{M}) where {N,M} = :($(N < M))
@generated (::InfiniteCardinal{N}, ::InfiniteCardinal{M}) where {N,M} = :($(N M))
Expand Down
13 changes: 13 additions & 0 deletions test/test_cardinality.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ using Infinities, Base64, Base.Checked, Test
@test !isless(Inf, ℵ₀) && !isless(ℵ₀, Inf)
@test isless(5, ℵ₀) && !isless(ℵ₀, 5)
@test isless(5, ℵ₁) && !isless(ℵ₁, 5)
@test !isless(RealInfinity(), ℵ₀)
@test isless(-RealInfinity(), ℵ₀)
@test !isless(ℵ₀, RealInfinity())
@test !isless(ℵ₀, -RealInfinity())
@test isless(RealInfinity(), ℵ₁)
@test isless(-RealInfinity(), ℵ₁)
@test !isless(ℵ₁, RealInfinity())
@test !isless(ℵ₁, -RealInfinity())
@test !isless(∞, ℵ₀)
@test !isless(ℵ₀, ∞)
@test isless(∞, ℵ₁)
@test !isless(ℵ₁, ∞)


@test !(ℵ₀ < ℵ₀) && !(ℵ₀ > ℵ₀)
@test ℵ₀ ℵ₀ && ℵ₀ ℵ₀
Expand Down

2 comments on commit 8580d78

@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/96744

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.1.8 -m "<description of version>" 8580d78d8ea2c676e720edcf041f21172417aec0
git push origin v0.1.8

Please sign in to comment.