Skip to content

Commit

Permalink
Merge pull request #10 from putianyi889/version-0.2.2
Browse files Browse the repository at this point in the history
version 0.2.2
  • Loading branch information
putianyi889 authored Feb 14, 2024
2 parents aeb8816 + 02e9f0a commit 84df0c9
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 6 deletions.
6 changes: 4 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name = "PTYQoL"
uuid = "551ad714-b11a-4605-8871-12721def4e72"
authors = ["Tianyi Pu <[email protected]> and contributors"]
version = "0.2.1"
version = "0.2.2"

[weakdeps]
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
CircularArrays = "7a955b69-7140-5f4e-a0ed-f168c5e2e749"
ContinuumArrays = "7ae1f121-cc2c-504b-ac30-9b923412ae5c"
Infinities = "e1ba4f0e-776d-440f-acd9-e1d2e9742647"
IntervalSets = "8197267c-284f-5f27-9208-e0e47529a953"
QuasiArrays = "c4ea9172-b204-11e9-377d-29865faadc5c"
ClassicalOrthogonalPolynomials = "b30e2e7b-c4ee-47da-9d5f-2c5c27239acd"
Expand All @@ -18,6 +19,7 @@ AlgebraicNumbers = "e86d093a-a386-599e-b7c7-df0420c8bcba"
PTYQoLLinearAlgebraExt = "LinearAlgebra"
PTYQoLCircularArraysExt = "CircularArrays"
PTYQoLContinuumArraysExt = "ContinuumArrays"
PTYQoLInfinitiesExt = "Infinities"
PTYQoLIntervalSetsExt = "IntervalSets"
PTYQoLQuasiArraysExt = "QuasiArrays"
PTYQoLClassicalOrthogonalPolynomialsExt = "ClassicalOrthogonalPolynomials"
Expand All @@ -40,4 +42,4 @@ Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
AlgebraicNumbers = "e86d093a-a386-599e-b7c7-df0420c8bcba"

[targets]
test = ["Test", "Aqua", "LinearAlgebra", "Documenter", "DomainSets", "ContinuumArrays", "ClassicalOrthogonalPolynomials", "ArrayLayouts", "AlgebraicNumbers"]
test = ["Test", "Aqua", "LinearAlgebra", "Documenter", "DomainSets", "ContinuumArrays", "ClassicalOrthogonalPolynomials", "ArrayLayouts", "AlgebraicNumbers", "Infinities"]
7 changes: 7 additions & 0 deletions ext/PTYQoLClassicalOrthogonalPolynomialsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ AbstractJacobi{T}(a::Ultraspherical) where T = Ultraspherical{T}(a)

Jacobi{T}(a::Jacobi) where T = Jacobi(T(a.a), T(a.b))

# ambiguities
import Base: _sum
import ClassicalOrthogonalPolynomials: Weighted, ChebyshevU, PiecewiseInterlace, BlockBroadcastArray
_sum(::Weighted{T,<:ChebyshevU}, ::Colon) where T = @assert Colon()==1
_sum(::Weighted{T,<:Chebyshev}, ::Colon) where T = @assert Colon()==1
_sum(P::PiecewiseInterlace, ::Colon) = BlockBroadcastArray(hcat, unitblocks.(_sum.(P.args, Colon()))...)

end
54 changes: 54 additions & 0 deletions ext/PTYQoLInfinitiesExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module PTYQoLInfinitiesExt

import Base: +, -, *, div, cld, mod, ==, <, isless, , fld
import Base.Checked: checked_sub, checked_mul
import Infinities: InfiniteCardinal, ∞, Infinity, ComplexInfinity, RealInfinity, NotANumber, ℵ₀

+(::InfiniteCardinal, x::Rational) =+ x
+(x::Rational, ::InfiniteCardinal) = x +
+(::InfiniteCardinal, x::Complex{Bool}) =+ x
+(::InfiniteCardinal, x::Complex) =+ x

-(x::InfiniteCardinal, y::InfiniteCardinal) = x > y ? x : -
-(x::Infinity, y::ComplexInfinity) = x + (-y)
-(::InfiniteCardinal, x::Complex{Bool}) =- x
-(x::Complex, ::InfiniteCardinal) = x -

*(x::InfiniteCardinal, y::InfiniteCardinal) = max(x,y)
*(x::InfiniteCardinal, y::Complex) = y*x
*(x::RealInfinity, y::Complex{Bool}) = ComplexInfinity(x)*y
*(a::Complex{Bool}, y::Infinity) = a*ComplexInfinity(y)
*(a::Complex{Bool},y::RealInfinity) = a*ComplexInfinity(y)
*(a::Rational, ::InfiniteCardinal) = a *
*(a::InfiniteCardinal, b::Rational) = b*a

div(x::InfiniteCardinal, ::Rational) = x

cld(x::Rational, ::InfiniteCardinal) = signbit(x) ? zero(x) : one(x)
cld(x::InfiniteCardinal, ::Rational) = x

fld(x::InfiniteCardinal, ::Rational) = x

mod(::RealInfinity, ::InfiniteCardinal) = NotANumber()

==(x::Complex, y::RealInfinity) = y==x
==(x::AbstractIrrational, y::RealInfinity) = y==x
==(x::RealInfinity, y::AbstractIrrational) = isinf(y) && signbit(y) == signbit(x)
==(::InfiniteCardinal, y::AbstractIrrational) === y
==(y::AbstractIrrational, x::Infinity) = x == y
==(x::AbstractIrrational, ::InfiniteCardinal) = x ==
==(y::Complex, x::Infinity) = x == y

<(::InfiniteCardinal, ::Rational) = false
<(x::Rational, ::InfiniteCardinal{0}) = x <

(::InfiniteCardinal{0}, x::Rational) = x

isless(::InfiniteCardinal, ::InfiniteCardinal{0}) = false
isless(x::RealInfinity, y::ComplexInfinity{Bool}) = signbit(x) && y -

checked_sub(::InfiniteCardinal{0}, ::InfiniteCardinal{0}) = NotANumber()

checked_mul(::InfiniteCardinal{0}, ::InfiniteCardinal{0}) = ℵ₀

end # module
4 changes: 2 additions & 2 deletions src/Utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -246,5 +246,5 @@ julia> fracpochhammer(1, 2, 0.5, 1, 3) # (1 * 1.5 * 2) / (2 * 3 * 4)
0.125
```
"""
fracpochhammer(a,b,n) = prod(range(a,length=n)./range(b,length=n));
fracpochhammer(a,b,stepa,stepb,n) = prod(range(a,step=stepa,length=n)./range(b,step=stepb,length=n));
fracpochhammer(a,b,n) = prod(x/y for (x,y) in zip(range(a,length=n),range(b,length=n)));
fracpochhammer(a,b,stepa,stepb,n) = prod(x/y for (x,y) in zip(range(a,step=stepa,length=n),range(b,step=stepb,length=n)));
32 changes: 30 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,14 @@ end
end
@testset "AlgebraicNumbers" begin
using AlgebraicNumbers
@test sincospi(1//3) == sincosd(60) == sincospi(1/3)
@test tanpi(1//3) == tanpi(1/3)
@test sincospi(1//3) == sincosd(60) == (sqrt(AlgebraicNumber(3))/2, 0.5)
@test tanpi(1//3) == sqrt(AlgebraicNumber(3))
@test sincospi(1//3) isa NTuple{2,AlgebraicNumber}
@test tanpi(1//3) isa AlgebraicNumber
end
@testset "Infinities" begin
using Infinities
end
end

using Documenter
Expand All @@ -130,4 +133,29 @@ end
using Aqua
@testset "Project quality" begin
Aqua.test_all(PTYQoL, ambiguities=true, piracies=false, deps_compat=false)
end

@testset "Ambiguities" begin
ambi = detect_ambiguities(Base, PTYQoL, Infinities)
internal = similar(ambi, 0)
extension = similar(ambi, 0)
external = similar(ambi, 0)
while !isempty(ambi)
inst = pop!(ambi)
if inst[1].module == PTYQoL || inst[2].module == PTYQoL
push!(internal, inst)
elseif inst[1].module == Base || inst[2].module == Base
push!(extension, inst)
else
push!(external, inst)
end
end
if !isempty(internal)
display(internal)
@test length(internal) == 0
end
if !isempty(extension)
display(extension)
@test_skip length(extension) == 0
end
end

0 comments on commit 84df0c9

Please sign in to comment.