Skip to content

Commit

Permalink
Add Compats to maintain v0.6 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
darwindarak committed Jun 30, 2018
1 parent d20f8ca commit 5c93d4b
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 31 deletions.
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
julia 0.7
Compat
Documenter
DocStringExtensions
Interpolations
Expand Down
5 changes: 5 additions & 0 deletions docs/src/manual/elements.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
```@meta
DocTestSetup = quote
using PotentialFlow
using Compat
srand(1)
end
```
Expand Down Expand Up @@ -119,3 +120,7 @@ Bodies.transform_velocity!
```@index
Pages = ["elements.md"]
```

```@meta
DocTestSetup = nothing
```
5 changes: 5 additions & 0 deletions docs/src/manual/motions.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
CurrentModule = Plates.RigidBodyMotions
DocTestSetup = quote
using PotentialFlow
using Compat
srand(1)
end
```
Expand Down Expand Up @@ -190,3 +191,7 @@ Order = [:type, :function]
```@index
Pages = ["motions.md"]
```

```@meta
DocTestSetup = nothing
```
5 changes: 5 additions & 0 deletions docs/src/manual/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -252,3 +253,7 @@ savefig("final_clusters.svg"); nothing # hide
```@raw html
<object data="final_clusters.svg" type="image/svg+xml"></object>
```

```@meta
DocTestSetup = nothing
```
4 changes: 3 additions & 1 deletion src/Elements.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Elements

using Compat

export Element, Singleton, Group, kind, @kind, circulation, flux, streamfunction,
conftransform, inverse_conftransform, jacobian, image

Expand All @@ -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

Expand Down
30 changes: 16 additions & 14 deletions src/Motions.jl
Original file line number Diff line number Diff line change
@@ -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!,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}:
Expand All @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions src/PotentialFlow.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ __precompile__()
module PotentialFlow

using Reexport
using Compat

include("Properties.jl")
include("Utils.jl")
Expand Down
1 change: 1 addition & 0 deletions src/RigidBodyMotions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module RigidBodyMotions
export RigidBodyMotion, Kinematics, d_dt

using DocStringExtensions
using Compat
import ForwardDiff
import Base: +, *, -, >>, <<, show

Expand Down
1 change: 1 addition & 0 deletions src/elements/Blobs.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Blobs

export Blob
using Compat

using ..Elements
import ..Motions: induce_velocity, mutually_induce_velocity!, self_induce_velocity!, advect
Expand Down
22 changes: 11 additions & 11 deletions src/elements/Bodies.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Bodies

using DocStringExtensions

using Compat

using ..Points
using ..Blobs
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand All @@ -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.
"""
Expand All @@ -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*α)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/elements/Doublets.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Doublets

using Compat

using ..Elements
using ..Motions

Expand Down
1 change: 1 addition & 0 deletions src/elements/Plates.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/elements/Points.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Points

using Compat
export Point

using ..Elements
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/elements/Sheets.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Sheets

using Compat
export Sheet

using MappedArrays
Expand Down
2 changes: 2 additions & 0 deletions src/elements/Source.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Source

using Compat

import ..Points
import ..Blobs
import ..Elements: circulation, flux
Expand Down
6 changes: 4 additions & 2 deletions src/elements/Vortex.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Vortex

using Compat

import ..Elements
import ..Elements: circulation, flux, impulse

Expand All @@ -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 `Γ`.
Expand Down Expand Up @@ -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 `δ`.
Expand Down
3 changes: 2 additions & 1 deletion src/elements/plates/chebyshev.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Chebyshev

using Compat
import Base: *, \
import FFTW

Expand All @@ -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

"""
Expand Down
2 changes: 1 addition & 1 deletion src/elements/sheets/surgery.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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₌]
Expand Down

0 comments on commit 5c93d4b

Please sign in to comment.