Skip to content

Commit

Permalink
rename ishalfoddinteger to ishalfodd
Browse files Browse the repository at this point in the history
  • Loading branch information
hyrodium committed Dec 5, 2023
1 parent 21d121a commit b0bc2e5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions src/HalfIntegers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export
# Functions
half,
ishalfinteger,
ishalfoddinteger,
ishalfodd,
onehalf,
twice

Expand Down Expand Up @@ -563,27 +563,27 @@ ishalfinteger(::AbstractIrrational) = false
ishalfinteger(::Missing) = missing

"""
ishalfoddinteger(x)
ishalfodd(x)
Test whether `x` is numerically equal to some half-odd-integer.
# Examples
```jldoctest
julia> ishalfoddinteger(3.5)
julia> ishalfodd(3.5)
true
julia> ishalfoddinteger(2)
julia> ishalfodd(2)
false
julia> ishalfoddinteger(1//3)
julia> ishalfodd(1//3)
false
```
"""
ishalfoddinteger(x::Number) = _isodd(twice(x))
ishalfoddinteger(x::Rational) = denominator(x) == 2
ishalfoddinteger(::Integer) = false
ishalfoddinteger(::Missing) = missing
ishalfodd(x::Number) = _isodd(twice(x))
ishalfodd(x::Rational) = denominator(x) == 2
ishalfodd(::Integer) = false
ishalfodd(::Missing) = missing

if VERSION v"1.7"
_isodd(x) = isodd(x)
Expand Down
2 changes: 1 addition & 1 deletion test/customtypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Base.convert(::Type{One}, x::Int) = x == 1 ? One() : error("can't convert $x to
@testset "Properties" begin
@test isfinite(MyHalfInt(2))
@test ishalfinteger(MyHalfInt(3/2))
@test ishalfoddinteger(MyHalfInt(3/2))
@test ishalfodd(MyHalfInt(3/2))
@test isinteger(MyHalfInt(3))
@test !isinteger(MyHalfInt(3/2))
@test iszero(MyHalfInt(0))
Expand Down
32 changes: 16 additions & 16 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -374,22 +374,22 @@ end
@test !ishalfinteger(im)
end

@testset "ishalfoddinteger" begin
@testset "ishalfodd" begin
for T in (halfinttypes..., halfuinttypes..., :BigHalfInt)
@eval @test !ishalfoddinteger($T(3))
@eval @test ishalfoddinteger($T(5/2))
end
@test !ishalfoddinteger(5)
@test !ishalfoddinteger(big(-5))
@test ishalfoddinteger(5//2)
@test ishalfoddinteger(-3//2)
@test !ishalfoddinteger(4//3)
@test !ishalfoddinteger(2.0)
@test ishalfoddinteger(-7.5)
@test !ishalfoddinteger(2.3)
@test !ishalfoddinteger(π)
@test !ishalfoddinteger(ℯ)
@test !ishalfoddinteger(im)
@eval @test !ishalfodd($T(3))
@eval @test ishalfodd($T(5/2))
end
@test !ishalfodd(5)
@test !ishalfodd(big(-5))
@test ishalfodd(5//2)
@test ishalfodd(-3//2)
@test !ishalfodd(4//3)
@test !ishalfodd(2.0)
@test ishalfodd(-7.5)
@test !ishalfodd(2.3)
@test !ishalfodd(π)
@test !ishalfodd(ℯ)
@test !ishalfodd(im)
end

@testset "isinteger" begin
Expand Down Expand Up @@ -1708,7 +1708,7 @@ end
@test onehalf(missing) === onehalf(Missing) === missing

@test ishalfinteger(missing) === missing
@test ishalfoddinteger(missing) === missing
@test ishalfodd(missing) === missing
end

include("ranges.jl")
Expand Down

0 comments on commit b0bc2e5

Please sign in to comment.