Skip to content

Commit

Permalink
Revert "Get IntervalArithmetic.jl ready for Julia 1.0 (#194)"
Browse files Browse the repository at this point in the history
This reverts commit 33ab553.
  • Loading branch information
dpsanders authored Sep 3, 2018
1 parent 33ab553 commit 517473d
Show file tree
Hide file tree
Showing 42 changed files with 841 additions and 749 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@ os:
- osx

julia:
- 0.7
- 1.0
- 0.6
- nightly

#matrix:
# allow_failures:
# - julia: nightly
matrix:
allow_failures:
- julia: nightly

notifications:
email: false

after_success:
- julia -e 'using Pkg; Pkg.add("Documenter")'
- julia -e 'Pkg.add("Documenter")'
- julia -e 'cd(Pkg.dir("IntervalArithmetic")); include(joinpath("docs", "make.jl"))'
- julia -e 'cd(Pkg.dir("IntervalArithmetic")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder()); Codecov.submit(process_folder())'
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ setdisplay(:full)
- `bisect` function in `ValidatedNumerics.RootFinding` for bisecting `Interval`s and `IntervalBox`es #217

### Other
- Many tests use `Test` instead of `FactCheck` #205
- Many tests use `Base.Test` instead of `FactCheck` #205
- Miscellaneous bugfixes

## v0.6
Expand Down
13 changes: 7 additions & 6 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
julia 0.7
CRlibm 0.7
StaticArrays 0.8
FastRounding 0.1.2
SetRounding 0.2
RecipesBase 0.5
julia 0.6
CRlibm 0.6
StaticArrays 0.5
FastRounding 0.0.4
AdjacentFloats 0.0.5
RecipesBase
Compat 0.69.0
53 changes: 28 additions & 25 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
environment:
matrix:
- julia_version: 0.7
- julia_version: 1
- julia_version: nightly

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: nightly
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-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"

# uncomment the following lines to allow failures on nightly julia
# (tests will run but not make your overall status red)
matrix:
allow_failures:
- 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"

branches:
only:
- master
- /release-.*/

notifications:
- provider: Email
Expand All @@ -26,18 +23,24 @@ notifications:
on_build_status_changed: false

install:
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
# If there's a newer build queued for the same PR, cancel this one
- ps: if ($env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_NUMBER -ne ((Invoke-RestMethod `
https://ci.appveyor.com/api/projects/$env:APPVEYOR_ACCOUNT_NAME/$env:APPVEYOR_PROJECT_SLUG/history?recordsNumber=50).builds | `
Where-Object pullRequestId -eq $env:APPVEYOR_PULL_REQUEST_NUMBER)[0].buildNumber) { `
throw "There are newer queued builds for this pull request, failing early." }
# 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

build_script:
- echo "%JL_BUILD_SCRIPT%"
- C:\julia\bin\julia -e "%JL_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();
Pkg.clone(pwd(), \"IntervalArithmetic\"); Pkg.build(\"IntervalArithmetic\")"

test_script:
- echo "%JL_TEST_SCRIPT%"
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"

# # Uncomment to support code coverage upload. Should only be enabled for packages
# # which would have coverage gaps without running on Windows
# on_success:
# - echo "%JL_CODECOV_SCRIPT%"
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"
- C:\projects\julia\bin\julia -e "Pkg.test(\"IntervalArithmetic\")"
2 changes: 1 addition & 1 deletion docs/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ to an `Interval{BigFloat}`, and then use routines from the `MPFR` library

- `^`
- `exp2`, `exp10`
- `atan`, `atanh`
- `atan2`, `atanh`

Note, in particular, that in order to obtain correct rounding for the power function (`^`),
intervals are converted to and from `BigFloat`; this implies a significant slow-down in this case.
Expand Down
37 changes: 16 additions & 21 deletions src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ __precompile__(true)
module IntervalArithmetic

import CRlibm

using StaticArrays
using FastRounding
using SetRounding

using Markdown

using LinearAlgebra
import LinearAlgebra: ×, dot
export ×, dot
using AdjacentFloats
using Compat

if VERSION <= v"0.7.0-DEV.2004"
import Base: ×, dot
import Compat.Sys
export
else
using Markdown
import Base:
import LinearAlgebra: ×, dot
end


import Base:
Expand All @@ -23,26 +27,24 @@ import Base:
in, zero, one, eps, typemin, typemax, abs, abs2, real, min, max,
sqrt, exp, log, sin, cos, tan, inv,
exp2, exp10, log2, log10,
asin, acos, atan,
asin, acos, atan, atan2,
sinh, cosh, tanh, asinh, acosh, atanh,
union, intersect, isempty,
convert, promote_rule, eltype, size,
BigFloat, float, widen, big,
, , , , eps,
, , , eps,
floor, ceil, trunc, sign, round,
expm1, log1p,
precision,
isfinite, isnan, isinf, iszero,
show,
show, showall,
isinteger, setdiff,
parse, hash

import Base: # for IntervalBox
broadcast, length,
getindex, setindex,
iterate, eltype

import .Broadcast: broadcasted
start, next, done, eltype

export
AbstractInterval, Interval,
Expand All @@ -65,13 +67,6 @@ export
export
setindex # re-export from StaticArrays for IntervalBox


if VERSION < v"1.0-dev"
import Base.showall
end

export showall

import Base: rounding, setrounding, setprecision


Expand Down
2 changes: 1 addition & 1 deletion src/bisect.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end
Bisect the `IntervalBox` `X` at position α ∈ [0,1] along its longest side.
"""
function bisect(X::IntervalBox, α=where_bisect)
i = argmax(diam.(X)) # find longest side
i = indmax(diam.(X)) # find longest side

return bisect(X, i, α)
end
Expand Down
9 changes: 3 additions & 6 deletions src/decorations/functions.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# This file is part of the IntervalArithmetic.jl package; MIT licensed

Base.literal_pow(::typeof(^), x::DecoratedInterval{T}, ::Val{p}) where {T,p} = x^p


# zero, one
zero(a::DecoratedInterval{T}) where T<:Real = DecoratedInterval(zero(T))
zero(::Type{DecoratedInterval{T}}) where T<:Real = DecoratedInterval(zero(T))
Expand Down Expand Up @@ -258,7 +255,7 @@ following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
""" union


## Functions on unrestricted domains; tan and atan are treated separately
## Functions on unrestricted domains; tan and atan2 are treated separately
unrestricted_functions =(
:exp, :exp2, :exp10,
:sin, :cos,
Expand Down Expand Up @@ -293,10 +290,10 @@ function decay(a::DECORATION)
ill
end

function atan(yy::DecoratedInterval{T}, xx::DecoratedInterval{T}) where T
function atan2(yy::DecoratedInterval{T}, xx::DecoratedInterval{T}) where T
x = interval_part(xx)
y = interval_part(yy)
r = atan(y, x)
r = atan2(y, x)
d = decoration(r)
d = min(d, decoration(xx), decoration(yy))
# Check cases when decoration is trv and decays (from com or dac)
Expand Down
8 changes: 4 additions & 4 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,15 @@ end
function round_string(x::BigFloat, digits::Int, r::RoundingMode)

lng = digits + Int32(8)
buf = Array{UInt8}(undef, lng + 1)
@compat buf = Array{UInt8}(undef, lng + 1)

lng = ccall((:mpfr_snprintf,:libmpfr), Int32,
(Ptr{UInt8}, Culong, Ptr{UInt8}, Int32, Ref{BigFloat}...),
buf, lng + 1, "%.$(digits)R*g", Base.MPFR.to_mpfr(r), x)

repr = unsafe_string(pointer(buf))

repr = replace(repr, "nan" => "NaN")
@compat repr = replace(repr, "nan" => "NaN")

return repr
end
Expand All @@ -144,8 +144,8 @@ function basic_representation(a::Interval, format=nothing)
bb = round_string(a.hi, sigfigs, RoundUp)

output = "[$aa, $bb]"
output = replace(output, "inf" => "")
output = replace(output, "Inf" => "")
@compat output = replace(output, "inf" => "")
@compat output = replace(output, "Inf" => "")

elseif format == :full
output = "Interval($(a.lo), $(a.hi))"
Expand Down
1 change: 0 additions & 1 deletion src/intervals/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ promote_rule(::Type{BigFloat}, ::Type{Interval{T}}) where T<:Real =


# convert methods:
convert(::Type{Interval{T}}, x::Bool) where {T} = convert(Interval{T}, Int(x))
convert(::Type{Interval{T}}, x::Real) where {T} = atomic(Interval{T}, x)
convert(::Type{Interval{T}}, x::T) where {T<:Real} = Interval{T}(x)
convert(::Type{Interval{T}}, x::Interval{T}) where {T} = x
Expand Down
8 changes: 4 additions & 4 deletions src/intervals/rounding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ for mode in (:Down, :Up)
mode2 = Symbol("Round", mode)

if mode == :Down
directed = :prevfloat
directed = :prev_float
else
directed = :nextfloat
directed = :next_float
end

# binary functions:
for f in (:+, :-, :*, :/, :atan)
for f in (:+, :-, :*, :/, :atan2)

@eval function $f(::IntervalRounding{:slow},
a::T, b::T, $mode1) where T<:AbstractFloat
Expand Down Expand Up @@ -233,7 +233,7 @@ function _setrounding(::Type{Interval}, rounding_type::Symbol)
roundtype = IntervalRounding{:slow}()
end

for f in (:^, :atan)
for f in (:^, :atan2)

@eval $f(a::T, b::T, r::RoundingMode) where {T<:AbstractFloat} = $f($roundtype, a, b, r)
end
Expand Down
Loading

0 comments on commit 517473d

Please sign in to comment.