Skip to content

fix deprecations for 0.7/1.0 #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
environment:
matrix:
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
- julia_version: 0.7
- julia_version: latest

platform:
- x86 # 32-bit
- x64 # 64-bit

## uncomment the following lines to allow failures on nightly julia
## (tests will run but not make your overall status red)
#matrix:
# allow_failures:
# - julia_version: latest

branches:
only:
Expand All @@ -17,19 +25,12 @@ notifications:
on_build_status_changed: false

install:
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# Download most recent Julia Windows binary
- ps: (new-object net.webclient).DownloadFile(
$env:JULIA_URL,
"C:\projects\julia-binary.exe")
# Run installer silently, output to C:\projects\julia
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))

build_script:
# Need to convert from shallow to complete for Pkg.clone to work
- IF EXIST .git\shallow (git fetch --unshallow)
- C:\projects\julia\bin\julia -e "versioninfo();
using Pkg; Pkg.clone(pwd(), \"FixedPointNumbers\"); Pkg.build(\"FixedPointNumbers\")"
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"

test_script:
- C:\projects\julia\bin\julia -e "using Pkg; Pkg.test(\"FixedPointNumbers\")"
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
17 changes: 6 additions & 11 deletions src/FixedPointNumbers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ using Base: reducedim_initarray
import Base: ==, <, <=, -, +, *, /, ~, isapprox,
convert, promote_rule, show, isinteger, abs, decompose,
isnan, isinf, isfinite,
zero, oneunit, one, typemin, typemax, realmin, realmax, eps, sizeof, reinterpret,
zero, oneunit, one, typemin, typemax, floatmin, floatmax, eps, sizeof, reinterpret,
float, trunc, round, floor, ceil, bswap,
div, fld, rem, mod, mod1, fld1, min, max, minmax,
start, next, done, rand
if isdefined(Base, :rem1)
import Base: rem1
end
rand

using Base: @pure

# T => BaseType
Expand Down Expand Up @@ -60,8 +58,8 @@ isinteger(x::FixedPoint{T,f}) where {T,f} = (x.i&(1<<f-1)) == 0
# traits
typemax(::Type{T}) where {T <: FixedPoint} = T(typemax(rawtype(T)), 0)
typemin(::Type{T}) where {T <: FixedPoint} = T(typemin(rawtype(T)), 0)
realmin(::Type{T}) where {T <: FixedPoint} = eps(T)
Copy link
Member

Choose a reason for hiding this comment

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

Should remove start, next, done on line 13?

Copy link
Contributor

Choose a reason for hiding this comment

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

done

realmax(::Type{T}) where {T <: FixedPoint} = typemax(T)
floatmin(::Type{T}) where {T <: FixedPoint} = eps(T)
floatmax(::Type{T}) where {T <: FixedPoint} = typemax(T)

widen1(::Type{Int8}) = Int16
widen1(::Type{UInt8}) = UInt16
Expand Down Expand Up @@ -153,10 +151,7 @@ for f in (:div, :fld, :fld1)
$f(x::T, y::T) where {T <: FixedPoint} = $f(reinterpret(x),reinterpret(y))
end
end
for f in (:rem, :mod, :mod1, :rem1, :min, :max)
if f === :rem1 && !isdefined(Base, :rem1)
continue
end
for f in (:rem, :mod, :mod1, :min, :max)
@eval begin
$f(x::T, y::T) where {T <: FixedPoint} = T($f(reinterpret(x),reinterpret(y)),0)
end
Expand Down
4 changes: 2 additions & 2 deletions test/fixed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ for T in (Fixed{Int8,8}, Fixed{Int16,8}, Fixed{Int16,10}, Fixed{Int32,16})
end
end

@testset "realmin" begin
@testset "floatmin" begin
# issue #79
@test realmin(Q11f4) == Q11f4(0.06)
@test floatmin(Q11f4) == Q11f4(0.06)
end

@testset "Disambiguation constructors" begin
Expand Down
2 changes: 1 addition & 1 deletion test/normed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for T in (FixedPointNumbers.UF..., UF2...)
@test one(T) == 1
@test one(T) * one(T) == one(T)
@test typemin(T) == 0
@test realmin(T) == eps(T)
@test floatmin(T) == eps(T)
@test eps(zero(T)) == eps(typemax(T))
@test sizeof(T) == sizeof(FixedPointNumbers.rawtype(T))
end
Expand Down