Skip to content

Commit

Permalink
Merge branch 'master' into fix_display_recursion
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolaru authored Jun 12, 2021
2 parents 337ce67 + a3dc27f commit 09a4036
Show file tree
Hide file tree
Showing 25 changed files with 358 additions and 273 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: CI
on:
- push
- pull_request
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
strategy:
fail-fast: false
matrix:
version:
- '1.5'
- '^1.6.0-0'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
- x86
exclude:
- os: macOS-latest
arch: x86
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
15 changes: 15 additions & 0 deletions .github/workflows/CompactHelper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: CompatHelper
on:
schedule:
- cron: 0 0 * * *
workflow_dispatch:
jobs:
CompatHelper:
runs-on: ubuntu-latest
steps:
- name: Pkg.add("CompatHelper")
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
- name: CompatHelper.main()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia -e 'using CompatHelper; CompatHelper.main()'
7 changes: 5 additions & 2 deletions .github/workflows/TagBot.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
name: TagBot
on:
schedule:
- cron: 0 * * * *
issue_comment:
types:
- created
workflow_dispatch:
jobs:
TagBot:
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
runs-on: ubuntu-latest
steps:
- uses: JuliaRegistries/TagBot@v1
Expand Down
39 changes: 0 additions & 39 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
`IntervalArithmetic.jl` is licensed under the MIT "Expat" License:

> Copyright (c) 2014-2020: David P. Sanders & Luis Benet
> Copyright (c) 2014-2021: David P. Sanders & Luis Benet
>
> Permission is hereby granted, free of charge, to any person obtaining
> a copy of this software and associated documentation files (the
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "IntervalArithmetic"
uuid = "d1acc4aa-44c8-5952-acd4-ba5d80a2a253"
repo = "https://github.com/JuliaIntervals/IntervalArithmetic.jl.git"
version = "0.17.5"
version = "0.18.2"

[deps]
CRlibm = "96374032-68de-5a5b-8d9e-752f78720389"
Expand All @@ -21,7 +21,7 @@ Polynomials = "0.7"
RecipesBase = "1.0"
RoundingEmulator = "0.2"
SetRounding = "0.2"
StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12"
StaticArrays = "0.8, 0.9, 0.10, 0.11, 0.12, 1.0"
julia = "1.3, 1.4, 1.5"

[extras]
Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# IntervalArithmetic.jl #

[![Build Status](https://travis-ci.org/JuliaIntervals/IntervalArithmetic.jl.svg?branch=master)](https://travis-ci.org/JuliaIntervals/IntervalArithmetic.jl)
[![Coverage Status](https://coveralls.io/repos/github/JuliaIntervals/IntervalArithmetic.jl/badge.svg?branch=master)](https://coveralls.io/github/JuliaIntervals/IntervalArithmetic.jl?branch=master)
[![codecov](https://codecov.io/gh/JuliaIntervals/IntervalArithmetic.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaIntervals/IntervalArithmetic.jl)
[![Build Status](https://github.com/JuliaIntervals/IntervalArithmetic.jl/workflows/CI/badge.svg)](https://github.com/JuliaIntervals/IntervalArithmetic.jl/actions/workflows/CI.yml)
[![coverage](https://codecov.io/gh/JuliaIntervals/IntervalArithmetic.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaIntervals/IntervalArithmetic.jl)

[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaIntervals.github.io/IntervalArithmetic.jl/stable)
[![](https://img.shields.io/badge/docs-latest-blue.svg)](https://JuliaIntervals.github.io/IntervalArithmetic.jl/latest)
[![docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliaintervals.github.io/pages/packages/intervalarithmetic/)

[![DOI](https://zenodo.org/badge/87007945.svg)](https://zenodo.org/badge/latestdoi/87007945)

Expand All @@ -26,6 +24,10 @@ The aim of the package is correctness over speed, although performance considera
- Nikolay Kryukov
- John Verzani

## Documentation
Documentation for the package is available [here](https://juliaintervals.github.io/pages/packages/intervalarithmetic/).

The best way to learn how to use the package is to look at the tutorial, available in the organisation webpage [here](https://juliaintervals.github.io/pages/tutorials/tutorialArithmetic/).

## Installation
To install the package, from within Julia do
Expand Down
43 changes: 0 additions & 43 deletions appveyor.yml

This file was deleted.

4 changes: 2 additions & 2 deletions src/IntervalArithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import Base:
+, -, *, /, //, fma,
<, >, ==, !=, , ^, <=,
in, zero, one, eps, typemin, typemax, abs, abs2, real, min, max,
sqrt, exp, log, sin, cos, tan, cot, inv, cbrt, csc, hypot, sec,
sqrt, exp, log, sin, cos, tan, cot, inv, cbrt, csc, hypot, sec,
exp2, exp10, log2, log10,
asin, acos, atan,
sinh, cosh, tanh, coth, csch, sech, asinh, acosh, atanh, sinpi, cospi,
Expand Down Expand Up @@ -86,7 +86,7 @@ import Base: rounding, setrounding, setprecision

## Multidimensional
export
IntervalBox
IntervalBox, symmetric_box

## Decorations
export
Expand Down
3 changes: 2 additions & 1 deletion src/decorations/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,14 @@ in(x::T, a::DecoratedInterval) where T<:Real = in(x, interval(a))

## scalar functions: mig, mag and friends
scalar_functions = (
:mig, :mag, :inf, :sup, :mid, :diam, :radius, :dist, :eps, :midpoint_radius
:mig, :mag, :inf, :sup, :mid, :diam, :radius, :eps, :midpoint_radius
)

for f in scalar_functions
@eval $(f)(xx::DecoratedInterval{T}) where T = $f(interval(xx))
end

dist(xx::DecoratedInterval, yy::DecoratedInterval) = dist(interval(xx), interval(yy))

## Arithmetic function; / is treated separately
arithm_functions = ( :+, :-, :* )
Expand Down
4 changes: 2 additions & 2 deletions src/decorations/intervals.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ DecoratedInterval(I::Interval{T}, d::DECORATION) where T<:AbstractFloat =
DecoratedInterval{T}(I, d)

function DecoratedInterval(a::T, b::T, d::DECORATION) where T<:Real
a > b && return nai(T)
is_valid_interval(a, b) || return nai(T)
DecoratedInterval(Interval(a,b), d)
end

Expand All @@ -63,7 +63,7 @@ DecoratedInterval(a::T, b::S, d::DECORATION) where {T<:Real, S<:Real} =
DecoratedInterval(I::Interval) = DecoratedInterval(I, decoration(I))

function DecoratedInterval(a::T, b::T) where T<:Real
a > b && return nai(T)
is_valid_interval(a, b) || return nai(T)
DecoratedInterval(Interval(a,b))
end

Expand Down
51 changes: 44 additions & 7 deletions src/display.jl
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,11 @@ function subscriptify(n::Integer)
join( [Char(subscript_0 + i) for i in dig])
end

function superscriptify(n::Integer)
exps = ['', '¹', '²', '³', '', '', '', '', '', '']
dig = reverse(digits(n))
return join([exps[d+1] for d in dig])
end

# fall-back:
representation(a::Interval{T}, format=nothing) where T =
Expand Down Expand Up @@ -317,29 +322,61 @@ function representation(a::DecoratedInterval{T}, format=nothing) where T
end


function representation(X::IntervalBox, format=nothing)
function representation(X::IntervalBox{N, T}, format=nothing) where {N, T}

if format == nothing
format = display_params.format # default
end

if display_params.format == :full
return string("IntervalBox(", join(X.v, ", "), ")")
n = format == :full ? N : superscriptify(N)

if isempty(X)
format == :full && return string("IntervalBox(∅, ", n, ")")
return string("", n)
end

x = first(X)
if all(==(x), X)
if format == :full
return string("IntervalBox(", representation(x, format), ", ", n, ")")
elseif format == :midpoint
return string("(", representation(x, format), ")", n)
else
return string(representation(x, format), n)
end
end

if format == :full
full_str = representation.(X.v, :full)
return string("IntervalBox(", join(full_str, ", "), ")")
elseif format == :midpoint
return string("(", join(X.v, ") × ("), ")")
else
return join(X.v, " × ")
end

end

function representation(x::Complex{<:Interval}, format=nothing)

if format == nothing
format = display_params.format
end

format == :midpoint && return string('(', x.re, ')', " + ", '(', x.im, ')', "im")

return string(x.re, " + ", x.im, "im")
end

for T in (Interval, DecoratedInterval)
@eval show(io::IO, a::$T{S}) where S = print(io, representation(a))
@eval showfull(io::IO, a::$T{S}) where S = print(io, representation(a, :full))
@eval showfull(a::$T{S}) where S = showfull(stdout, a)
end

T = IntervalBox
@eval show(io::IO, a::$T) = print(io, representation(a))
@eval show(io::IO, ::MIME"text/plain", a::$T) = print(io, representation(a))
@eval showfull(io::IO, a::$T) = print(io, representation(a, :full))
for T in (IntervalBox, Complex{<:Interval})
@eval show(io::IO, a::$T) = print(io, representation(a))
@eval show(io::IO, ::MIME"text/plain", a::$T) = print(io, representation(a))
@eval showfull(io::IO, a::$T) = print(io, representation(a, :full))
@eval showfull(a::$T) = showfull(stdout, a)
end
4 changes: 2 additions & 2 deletions src/intervals/arithmetic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ convert(::Type{Integer}, a::Interval) = isinteger(a) ?
Splits `x` in `n` intervals of the same diameter, which are returned
as a vector.
"""
function mince(x::Interval, n)
@inline function mince(x::Interval, n)
nodes = range(x.lo, x.hi, length = n+1)
return [Interval(nodes[i], nodes[i+1]) for i in 1:length(nodes)-1]
return Interval.(nodes[1:n], nodes[2:n+1])
end
3 changes: 3 additions & 0 deletions src/intervals/conversion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,6 @@ atomic(::Type{Interval{Rational{T}}}, x::S) where {T<:Integer, S<:Float64} =

atomic(::Type{Interval{Rational{T}}}, x::S) where {T<:Integer, S<:BigFloat} =
Interval(rationalize(T, x))

atomic(::Type{Interval{Rational{T}}}, x::Interval{Rational{T}}) where {T<:Integer} =
Interval(x)
Loading

0 comments on commit 09a4036

Please sign in to comment.