From 5c93d4b5c3f2bb5378fe51e4063cd1fd69d2535f Mon Sep 17 00:00:00 2001 From: Darwin Darakananda Date: Sat, 30 Jun 2018 00:13:02 -0400 Subject: [PATCH] Add `Compat`s to maintain v0.6 compatibility --- REQUIRE | 1 + docs/src/manual/elements.md | 5 +++++ docs/src/manual/motions.md | 5 +++++ docs/src/manual/quickstart.md | 5 +++++ src/Elements.jl | 4 +++- src/Motions.jl | 30 ++++++++++++++++-------------- src/PotentialFlow.jl | 1 + src/RigidBodyMotions.jl | 1 + src/elements/Blobs.jl | 1 + src/elements/Bodies.jl | 22 +++++++++++----------- src/elements/Doublets.jl | 2 ++ src/elements/Plates.jl | 1 + src/elements/Points.jl | 3 ++- src/elements/Sheets.jl | 1 + src/elements/Source.jl | 2 ++ src/elements/Vortex.jl | 6 ++++-- src/elements/plates/chebyshev.jl | 3 ++- src/elements/sheets/surgery.jl | 2 +- 18 files changed, 64 insertions(+), 31 deletions(-) diff --git a/REQUIRE b/REQUIRE index 8347163..966bb2b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,4 +1,5 @@ julia 0.7 +Compat Documenter DocStringExtensions Interpolations diff --git a/docs/src/manual/elements.md b/docs/src/manual/elements.md index 40dfaab..f277e01 100644 --- a/docs/src/manual/elements.md +++ b/docs/src/manual/elements.md @@ -3,6 +3,7 @@ ```@meta DocTestSetup = quote using PotentialFlow +using Compat srand(1) end ``` @@ -119,3 +120,7 @@ Bodies.transform_velocity! ```@index Pages = ["elements.md"] ``` + +```@meta +DocTestSetup = nothing +``` diff --git a/docs/src/manual/motions.md b/docs/src/manual/motions.md index 8004a66..629b87f 100644 --- a/docs/src/manual/motions.md +++ b/docs/src/manual/motions.md @@ -4,6 +4,7 @@ CurrentModule = Plates.RigidBodyMotions DocTestSetup = quote using PotentialFlow + using Compat srand(1) end ``` @@ -190,3 +191,7 @@ Order = [:type, :function] ```@index Pages = ["motions.md"] ``` + +```@meta +DocTestSetup = nothing +``` diff --git a/docs/src/manual/quickstart.md b/docs/src/manual/quickstart.md index 8c7692b..ed606fb 100644 --- a/docs/src/manual/quickstart.md +++ b/docs/src/manual/quickstart.md @@ -5,6 +5,7 @@ The code examples here should be directly copy-paste-able into the Julia REPL (e ```@meta DocTestSetup = quote + using Compat srand(1) end ``` @@ -252,3 +253,7 @@ savefig("final_clusters.svg"); nothing # hide ```@raw html ``` + +```@meta +DocTestSetup = nothing +``` diff --git a/src/Elements.jl b/src/Elements.jl index 0592c89..0018870 100644 --- a/src/Elements.jl +++ b/src/Elements.jl @@ -1,5 +1,7 @@ module Elements +using Compat + export Element, Singleton, Group, kind, @kind, circulation, flux, streamfunction, conftransform, inverse_conftransform, jacobian, image @@ -21,7 +23,7 @@ macro kind(element, k) end) end -@kind Complex128 Singleton +@kind ComplexF64 Singleton kind(::AbstractArray{T}) where {T <: Union{Element, ComplexF64}} = Group kind(::Tuple) = Group diff --git a/src/Motions.jl b/src/Motions.jl index 693c591..ed6a642 100644 --- a/src/Motions.jl +++ b/src/Motions.jl @@ -1,5 +1,7 @@ module Motions +using Compat + export induce_velocity, induce_velocity!, allocate_velocity, self_induce_velocity, self_induce_velocity!, mutually_induce_velocity!, reset_velocity!, @@ -17,7 +19,7 @@ Compute the velocity induced by `element` on `target` `target` can be: -- a `Complex128` +- a `ComplexF64` - a subtype of `Vortex.PointSource` - an array or tuple of vortex elements @@ -28,12 +30,12 @@ while the `element` can be: # Example ```jldoctest -julia> z = rand(Complex128) +julia> z = rand(ComplexF64) 0.23603334566204692 + 0.34651701419196046im julia> point = Vortex.Point(z, rand()); -julia> srcs = Vortex.Point.(rand(Complex128, 10), rand(10)); +julia> srcs = Vortex.Point.(rand(ComplexF64, 10), rand(10)); julia> induce_velocity(z, srcs[1], 0.0) 0.08722212007570912 + 0.14002850279102955im @@ -51,20 +53,20 @@ julia> induce_velocity(point, srcs, 0.0) @property begin signature = induce_velocity(targ::Target, src::Source, t) preallocator = allocate_velocity - stype = Complex128 + stype = ComplexF64 end @doc """ allocate_velocity(srcs) -Allocate arrays of `Complex128` to match the structure of `srcs` +Allocate arrays of `ComplexF64` to match the structure of `srcs` # Example ```jldoctest -julia> points = Vortex.Point.(rand(Complex128, 2), rand(2)); +julia> points = Vortex.Point.(rand(ComplexF64, 2), rand(2)); -julia> blobs = Vortex.Blob.(rand(Complex128, 3), rand(3), rand(3)); +julia> blobs = Vortex.Blob.(rand(ComplexF64, 3), rand(3), rand(3)); julia> allocate_velocity(points) 2-element Array{Complex{Float64},1}: @@ -90,13 +92,13 @@ while the `element` can be: # Example ```jldoctest -julia> cluster₁ = Vortex.Point.(rand(Complex128, 5), rand(5)); +julia> cluster₁ = Vortex.Point.(rand(ComplexF64, 5), rand(5)); -julia> cluster₂ = Vortex.Point.(rand(Complex128, 5), rand(5)); +julia> cluster₂ = Vortex.Point.(rand(ComplexF64, 5), rand(5)); julia> targets = (cluster₁, cluster₂); -julia> sources = Vortex.Blob.(rand(Complex128), rand(10), 0.1); +julia> sources = Vortex.Blob.(rand(ComplexF64), rand(10), 0.1); julia> ẋs = allocate_velocity(targets); @@ -195,12 +197,12 @@ If `srcs` is provided, then the arrays in `vels` are resized their source counte # Example ```jldoctest -julia> ẋs = (rand(Complex128, 1), rand(Complex128, 1)) +julia> ẋs = (rand(ComplexF64, 1), rand(ComplexF64, 1)) (Complex{Float64}[0.236033+0.346517im], Complex{Float64}[0.312707+0.00790928im]) -julia> points = Vortex.Point.(rand(Complex128, 2), rand(2)); +julia> points = Vortex.Point.(rand(ComplexF64, 2), rand(2)); -julia> blobs = Vortex.Blob.(rand(Complex128, 3), rand(3), rand(3)); +julia> blobs = Vortex.Blob.(rand(ComplexF64, 3), rand(3), rand(3)); julia> reset_velocity!(ẋs, (points, blobs)); @@ -238,7 +240,7 @@ function reset_velocity!(m::RigidBodyMotion, src) end """ - advect(src::Element, velocity::Complex128, Δt) + advect(src::Element, velocity::ComplexF64, Δt) Return a new element that represents `src` advected by `velocity` over `Δt`. diff --git a/src/PotentialFlow.jl b/src/PotentialFlow.jl index 4cdefc3..08d0eb4 100644 --- a/src/PotentialFlow.jl +++ b/src/PotentialFlow.jl @@ -3,6 +3,7 @@ __precompile__() module PotentialFlow using Reexport +using Compat include("Properties.jl") include("Utils.jl") diff --git a/src/RigidBodyMotions.jl b/src/RigidBodyMotions.jl index 718069c..af9f7fa 100644 --- a/src/RigidBodyMotions.jl +++ b/src/RigidBodyMotions.jl @@ -3,6 +3,7 @@ module RigidBodyMotions export RigidBodyMotion, Kinematics, d_dt using DocStringExtensions +using Compat import ForwardDiff import Base: +, *, -, >>, <<, show diff --git a/src/elements/Blobs.jl b/src/elements/Blobs.jl index 711e19a..b7ad038 100644 --- a/src/elements/Blobs.jl +++ b/src/elements/Blobs.jl @@ -1,6 +1,7 @@ module Blobs export Blob +using Compat using ..Elements import ..Motions: induce_velocity, mutually_induce_velocity!, self_induce_velocity!, advect diff --git a/src/elements/Bodies.jl b/src/elements/Bodies.jl index 5353ce6..039b726 100644 --- a/src/elements/Bodies.jl +++ b/src/elements/Bodies.jl @@ -1,7 +1,7 @@ module Bodies using DocStringExtensions - +using Compat using ..Points using ..Blobs @@ -72,9 +72,9 @@ Body generated by: Schwarz-Christoffel map of unit circle to exterior of polygon centroid at 0.0 + 0.0im angle 0.0 -julia> a1 = 1; b1 = 0.1; ccoeff = Complex128[0.5(a1+b1),0,0.5(a1-b1)]; +julia> a1 = 1; b1 = 0.1; ccoeff = ComplexF64[0.5(a1+b1),0,0.5(a1-b1)]; -julia> Bodies.ConformalBody(ccoeff,Complex128(1.0),π/4) +julia> Bodies.ConformalBody(ccoeff,ComplexF64(1.0),π/4) Body generated by: Power series map centroid at 1.0 + 0.0im @@ -247,7 +247,7 @@ correction and subtracts the relative motion of the `body`. # Example ```jldoctest -julia> a1 = 1; b1 = 0.1; ccoeff = Complex128[0.5(a1+b1),0,0.5(a1-b1)]; +julia> a1 = 1; b1 = 0.1; ccoeff = ComplexF64[0.5(a1+b1),0,0.5(a1-b1)]; julia> body = Bodies.ConformalBody(ccoeff); @@ -276,12 +276,12 @@ julia> Bodies.transform_velocity!(ẋ, ẋ, sys, body) Constant (ċ = 0 + 0im, α̇ = 0), Complex{Float64}[0.0+0.785969im, 0.0-0.785969im]) ``` - transform_velocity(win, target::Complex128, body::ConformalBody) + transform_velocity(win, target::ComplexF64, body::ConformalBody) Returns the velocity in the physical plane from the velocity `win` in the circle plane. ```jldoctest -julia> a1 = 1; b1 = 0.1; ccoeff = Complex128[0.5(a1+b1),0,0.5(a1-b1)]; +julia> a1 = 1; b1 = 0.1; ccoeff = ComplexF64[0.5(a1+b1),0,0.5(a1-b1)]; julia> body = Bodies.ConformalBody(ccoeff,0.0+0.0im,π/4); @@ -414,7 +414,7 @@ function advect!(body₊::ConformalBody, body₋::ConformalBody, ṗ::RigidBodyM @get body₊ (m, c, α) - @. body₊.zs = rigid_transform(m.z,Complex128(c),α) + @. body₊.zs = rigid_transform(m.z,ComplexF64(c),α) return body₊ end @@ -441,7 +441,7 @@ end Compute the impulse per unit circulation of `src` and its associated bound vortex sheet on the conformally mapped `body` (its image vortex) -`src` can be either a `Complex128` or a subtype of `Vortex.PointSource`. +`src` can be either a `ComplexF64` or a subtype of `Vortex.PointSource`. In both cases, the position associated with `src` is interpreted in the circle plane of the conformal map. """ @@ -456,7 +456,7 @@ unit_impulse(src, body::ConformalBody) = unit_impulse(Elements.position(src), bo -function streamfunction(ζ::Complex128, b::PowerBody, Winf::Complex128, t) +function streamfunction(ζ::ComplexF64, b::PowerBody, Winf::ComplexF64, t) @get b (C, D, α, c) W̃inf = Winf*exp(im*α) @@ -494,9 +494,9 @@ tangent(z, α) = real(exp(-im*α)*z) unit_impulse(src, plate::Plate) Compute the impulse per unit circulation of `src` and its associated bound vortex sheet on `plate` (its image vortex) -`src` can be either a `Complex128` or a subtype of `Vortex.PointSource`. +`src` can be either a `ComplexF64` or a subtype of `Vortex.PointSource`. """ -function unit_impulse(z::Complex128, plate::Plate) +function unit_impulse(z::ComplexF64, plate::Plate) z̃ = 2(z - plate.c)*exp(-im*plate.α)/plate.L unit_impulse(z̃) end diff --git a/src/elements/Doublets.jl b/src/elements/Doublets.jl index 7568021..660b0c2 100644 --- a/src/elements/Doublets.jl +++ b/src/elements/Doublets.jl @@ -1,5 +1,7 @@ module Doublets +using Compat + using ..Elements using ..Motions diff --git a/src/elements/Plates.jl b/src/elements/Plates.jl index 4263809..36a6b09 100644 --- a/src/elements/Plates.jl +++ b/src/elements/Plates.jl @@ -1,6 +1,7 @@ module Plates using DocStringExtensions +using Compat export Plate, bound_circulation, bound_circulation!, enforce_no_flow_through!, vorticity_flux, suction_parameters, unit_impulse, force diff --git a/src/elements/Points.jl b/src/elements/Points.jl index ca0ef4b..ecda2f2 100644 --- a/src/elements/Points.jl +++ b/src/elements/Points.jl @@ -1,5 +1,6 @@ module Points +using Compat export Point using ..Elements @@ -14,7 +15,7 @@ An immutable structure representing a point source/vortex ## Fields -- `z::Complex128`: position +- `z::ComplexF64`: position - `S::T`: strength/circulation """ struct Point{T <: Number} <: Element diff --git a/src/elements/Sheets.jl b/src/elements/Sheets.jl index 65ca76b..110d4e7 100644 --- a/src/elements/Sheets.jl +++ b/src/elements/Sheets.jl @@ -1,5 +1,6 @@ module Sheets +using Compat export Sheet using MappedArrays diff --git a/src/elements/Source.jl b/src/elements/Source.jl index 18de374..d30bb74 100644 --- a/src/elements/Source.jl +++ b/src/elements/Source.jl @@ -1,5 +1,7 @@ module Source +using Compat + import ..Points import ..Blobs import ..Elements: circulation, flux diff --git a/src/elements/Vortex.jl b/src/elements/Vortex.jl index fab88a0..9bfc2a3 100644 --- a/src/elements/Vortex.jl +++ b/src/elements/Vortex.jl @@ -1,5 +1,7 @@ module Vortex +using Compat + import ..Elements import ..Elements: circulation, flux, impulse @@ -12,7 +14,7 @@ import ..Sheets #== Wrapper for a point vortex ==# """ - Vortex.Point(z::Complex128, Γ::Float64) + Vortex.Point(z::ComplexF64, Γ::Float64) A point vortex located at `z` with circulation `Γ`. @@ -43,7 +45,7 @@ Base.show(io::IO, s::Point) = print(io, "Vortex.Point($(s.z), $(s.S))") #== Wrapper for a vortex blob ==# """ - Vortex.Blob(z::Complex128, Γ::Float64, δ::Float64) + Vortex.Blob(z::ComplexF64, Γ::Float64, δ::Float64) A regularized point vortex located at `z` with circulation `Γ` and blob radius `δ`. diff --git a/src/elements/plates/chebyshev.jl b/src/elements/plates/chebyshev.jl index a56fbc2..00391d1 100644 --- a/src/elements/plates/chebyshev.jl +++ b/src/elements/plates/chebyshev.jl @@ -1,5 +1,6 @@ module Chebyshev +using Compat import Base: *, \ import FFTW @@ -26,7 +27,7 @@ end Gives `N` extrema Chebyshev points of type `T` in [-1 ,1]. """ function nodes(N, T = Float64) - T[cos(θ) for θ in range(π, stop=0, length=N)] + T[cos(θ) for θ in Compat.range(π, stop=0, length=N)] end """ diff --git a/src/elements/sheets/surgery.jl b/src/elements/sheets/surgery.jl index bc5d8b6..f844947 100644 --- a/src/elements/sheets/surgery.jl +++ b/src/elements/sheets/surgery.jl @@ -130,7 +130,7 @@ function remesh(sheet::Sheet{S}, Δs::Float64, params::Tuple = ()) where S N = ceil(Int, L[end]/Δs) - L₌ = range(0, stop=L[end], length=N) + L₌ = Compat.range(0, stop=L[end], length=N) z₌ = zspline[L₌] S₌ = Γspline[L₌]