Skip to content

Commit

Permalink
Add Compats to maintain v0.6 compatibility
Browse files Browse the repository at this point in the history
`round` in v0.6 does not take in keyword arguments
Have to add a `base` keyword argument now while waiting for
JuliaLang/Compat.jl#537
  • Loading branch information
darwindarak committed Jul 1, 2018
1 parent d20f8ca commit ab4f98c
Show file tree
Hide file tree
Showing 19 changed files with 76 additions and 42 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
```
1 change: 1 addition & 0 deletions docs/src/manual/velocities.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

```@meta
DocTestSetup = quote
using Compat
using PotentialFlow
srand(1)
end
Expand Down
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
13 changes: 7 additions & 6 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 Expand Up @@ -45,9 +46,9 @@ RigidBodyMotion(kin::Kinematics) = RigidBodyMotion(kin(0)..., kin)

function show(io::IO, m::RigidBodyMotion)
println(io, "Rigid Body Motion:")
println(io, " ċ = $(round(m.ċ, digits=2))")
println(io, " c̈ = $(round(m.c̈, digits=2))")
println(io, " α̇ = $(round(m.α̇, digits=2))")
println(io, " ċ = $(Compat.round(m.ċ, digits=2, base=10))")
println(io, " c̈ = $(Compat.round(m.c̈, digits=2, base=10))")
println(io, " α̇ = $(Compat.round(m.α̇, digits=2, base=10))")
print(io, " $(m.kin)")
end

Expand Down Expand Up @@ -378,13 +379,13 @@ struct Sinusoid <: Profile
ω::Float64
end
(s::Sinusoid)(t) = sin(s.ω*t)
show(io::IO, s::Sinusoid) = print(io, "Sinusoid (ω = $(round(s.ω, digits=2)))")
show(io::IO, s::Sinusoid) = print(io, "Sinusoid (ω = $(Compat.round(s.ω, digits=2, base=10)))")

struct EldredgeRamp <: Profile
aₛ::Float64
end
(r::EldredgeRamp)(t) = 0.5(log(2cosh(r.aₛ*t)) + r.aₛ*t)/r.aₛ
show(io::IO, r::EldredgeRamp) = print(io, "logcosh ramp (aₛ = $(round(r.aₛ, digits=2)))")
show(io::IO, r::EldredgeRamp) = print(io, "logcosh ramp (aₛ = $(Compat.round(r.aₛ, digits=2, base=10)))")

struct ColoniusRamp <: Profile
n::Int
Expand All @@ -403,6 +404,6 @@ function (r::ColoniusRamp)(t)
f*Δt^(r.n + 2)/(2r.n + 2)
end
end
show(io::IO, r::ColoniusRamp) = print(io, "power series ramp (n = $(round(r.n, digits=2)))")
show(io::IO, r::ColoniusRamp) = print(io, "power series ramp (n = $(Compat.round(r.n, digits=2, base=10)))")

end
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
26 changes: 13 additions & 13 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 All @@ -95,8 +95,8 @@ ConformalBody() = ConformalBody(PowerMap(ComplexF64(1)))

function Base.show(io::IO, b::ConformalBody)
println(io, "Body generated by: $(b.m)")
println(io, " centroid at $(round(b.c, digits=4))")
println(io, " angle $(round(b.α, digits=4))")
println(io, " centroid at $(Compat.round(b.c, digits=4, base=10))")
println(io, " angle $(Compat.round(b.α, digits=4, base=10))")
end


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
5 changes: 3 additions & 2 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 Expand Up @@ -295,8 +296,8 @@ include("plates/pressure.jl")

function Base.show(io::IO, p::Plate)
lesp, tesp = suction_parameters(p)
println(io, "Plate: N = $(p.N), L = $(p.L), c = $(p.c), α = $(round(rad2deg(p.α), digits=2))")
print(io, " LESP = $(round(lesp, digits=2)), TESP = $(round(tesp, digits=2))")
println(io, "Plate: N = $(p.N), L = $(p.L), c = $(p.c), α = $(Compat.round(rad2deg(p.α), digits=2, base=10))")
print(io, " LESP = $(Compat.round(lesp, digits=2, base=10)), TESP = $(Compat.round(tesp, digits=2, base=10))")
end

end
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
Loading

0 comments on commit ab4f98c

Please sign in to comment.