From 45643651ccafb4b8a2134904e26ca74a91c324a5 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Sun, 26 Jul 2015 23:35:38 -0400 Subject: [PATCH 1/2] 0.4 Compatibility --- REQUIRE | 1 + src/plot.jl | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/REQUIRE b/REQUIRE index 60ff731..955277e 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1 +1,2 @@ julia 0.3- +Compat diff --git a/src/plot.jl b/src/plot.jl index 77e199a..d463d94 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -1,13 +1,15 @@ +using Compat + # Currently Julia gives false for isa([1,2,3], Vector{Real}), so doing manually. typealias RealVector Union(Vector{Int}, Vector{Float64}) typealias RealMatrix Union(Matrix{Int}, Matrix{Float64}) -typealias PlotInputs Union(Vector{Function}, (RealVector, RealMatrix)) +typealias PlotInputs Union(Vector{Function}, @compat Tuple{RealVector, RealMatrix}) SUPER = utf16("\u2070\u00b9\u00b2\u00b3\u2074\u2075\u2076\u2077\u2078\u2079") # Find magnitude of difference between 2 nums, as digits before/after decimal. function magnitude(num1::Real, num2::Real) - -iround(log10(abs(num2 - num1))) + -round(Integer,log10(abs(num2 - num1))) end # See if this float happens to match common uses of constants like n*pi. @@ -16,9 +18,9 @@ function findsymbolic(num::Real) # Format strings for minus sign, superscript, multiples, and exponents. dash(x, super=false) = x >= 0 ? "" : super ? "⁻" : "-" - sup(x) = dash(x, true) * join([SUPER[d + 1] for d in reverse(digits(iround(abs(x))))]) - multiple(x) = iround(x) == 0 ? "0" : iround(x) == 1 ? "" : "$(iround(x))" - topower(n, x) = iround(x) == 0 ? "1" : iround(x) == 1 ? n : "$n$(sup(x))" + sup(x) = dash(x, true) * join([SUPER[d + 1] for d in reverse(digits(round(Integer,abs(x))))]) + multiple(x) = round(Integer,x) == 0 ? "0" : round(Integer,x) == 1 ? "" : "$(round(Integer,x))" + topower(n, x) = round(Integer,x) == 0 ? "1" : round(Integer,x) == 1 ? n : "$n$(sup(x))" # Split number between the absolute value and the minus sign, if any anum, sgn = abs(num), dash(num) @@ -87,14 +89,16 @@ function plot(data::PlotInputs, start::Real=-10, stop::Real=10; # The unicode braille chars are conveniently structured to support bitwise # manipulation, so we can just OR specific bits to set that dot to filled. - grid = fill(char(gridlines ? 0x2812 : 0x2800), cols, rows) + grid = fill((@compat Char(gridlines ? 0x2812 : 0x2800)), cols, rows) left, right = sides = ((0, 1, 2, 6), (3, 4, 5, 7)) function showdot(x, y) # Assumes x & y are already scaled to the grid. invy = (rows - y)*0.9999 - col, col2 = ifloor(x), ifloor(x*2) - row, row4 = ifloor(invy), ifloor(invy*4) + col, col2 = floor(Integer,x), floor(Integer,x*2) + row, row4 = floor(Integer,invy), floor(Integer,invy*4) # This does the bitwise OR to fill in a single dot out of the 8. - grid[col + 1, row + 1] |= 1 << sides[1 + (col2 & 1)][1 + (row4 & 3)] + grid[col + 1, row + 1] = @compat Char( + (@compat Int(grid[col + 1, row + 1])) | + (1 << sides[1 + (col2 & 1)][1 + (row4 & 3)])) end # If input is a function, sample it at each row & col to fill xvals & yvals. From ec93483ed5b774b51f79003f4958ba70db481a77 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Fri, 31 Jul 2015 16:50:59 -0400 Subject: [PATCH 2/2] Modernize travis --- .travis.yml | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0d79e87..f351d57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,17 +1,14 @@ -language: cpp -compiler: - - gcc +language: julia +os: + - linux + - osx +julia: + - release + - nightly notifications: - email: false -before_install: - - sudo add-apt-repository ppa:staticfloat/julia-deps -y - - sudo add-apt-repository ppa:staticfloat/julianightlies -y - - sudo apt-get update -qq -y - - sudo apt-get install git libpcre3-dev julia -y - - git config --global user.name "Travis User" - - git config --global user.email "travis@example.net" - - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + email: false script: - - julia --code-coverage ./test/runtests.jl + - if [[ -a .git/shallow ]]; then git fetch --unshallow; fi + - julia --check-bounds=yes -e 'Pkg.clone(pwd()); Pkg.build("$pkg"); Pkg.test("$pkg"; coverage=true) after_success: - - julia -e 'cd(Pkg.dir("TextPlots")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())' + - if [[ $JULIAVERSION = "juliareleases" && `uname` = "Linux" ]]; then julia -e 'cd(Pkg.dir("TextPlots")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'; fi