Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
remove Maybe and MaybeVector (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredclwong authored Apr 30, 2021
1 parent c2e3101 commit 51633e3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 37 deletions.
16 changes: 8 additions & 8 deletions src/Examples/docs_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Group examples that are used in the docs (examples.md)
export draw_cooketriplet, draw_schmidtcassegraintelescope, draw_lensconstruction, draw_zoomlenses, draw_HOEfocus, draw_HOEcollimate, draw_multiHOE, draw_stackedbeamsplitters

function draw_cooketriplet(filename::Maybe{AbstractString} = nothing)
function draw_cooketriplet(filename::Union{Nothing,AbstractString} = nothing)
g1, g2 = SCHOTT.N_SK16, SCHOTT.N_SF2
sys = AxisymmetricOpticalSystem{Float64}(DataFrame(
Surface = [:Object, 1, 2, 3, :Stop, 5, 6, :Image ],
Expand All @@ -30,7 +30,7 @@ function draw_cooketriplet(filename::Maybe{AbstractString} = nothing)
return sys
end

function draw_zoomlenses(filenames::MaybeVector{AbstractString} = repeat([nothing], 3))
function draw_zoomlenses(filenames::Vector{<:Union{Nothing,AbstractString}} = repeat([nothing], 3))
stops = [2.89, 3.99, 4.90]
zooms = [9.48, 4.48, 2.00]
dists = [4.46970613, 21.21, 43.81]
Expand All @@ -57,7 +57,7 @@ function draw_zoomlenses(filenames::MaybeVector{AbstractString} = repeat([nothin
return syss
end

function draw_schmidtcassegraintelescope(filename::Maybe{AbstractString} = nothing)
function draw_schmidtcassegraintelescope(filename::Union{Nothing,AbstractString} = nothing)
# glass entrance lens on telescope
topsurf = Plane(
SVector(0.0, 0.0, 1.0),
Expand Down Expand Up @@ -105,7 +105,7 @@ function draw_schmidtcassegraintelescope(filename::Maybe{AbstractString} = nothi
return nothing
end

function draw_lensconstruction(filename::Maybe{AbstractString} = nothing)
function draw_lensconstruction(filename::Union{Nothing,AbstractString} = nothing)
topsurface = leaf(
AcceleratedParametricSurface(
QTypeSurface(
Expand Down Expand Up @@ -142,7 +142,7 @@ function draw_lensconstruction(filename::Maybe{AbstractString} = nothing)
return nothing
end

function draw_HOEfocus(filename::Maybe{AbstractString} = nothing)
function draw_HOEfocus(filename::Union{Nothing,AbstractString} = nothing)
rect = Rectangle(5.0, 5.0, SVector(0.0, 0.0, 1.0), SVector(0.0, 0.0, 0.0))
int = HologramInterface(
SVector(0.0, -3.0, -20.0), ConvergingBeam,
Expand All @@ -165,7 +165,7 @@ function draw_HOEfocus(filename::Maybe{AbstractString} = nothing)
return nothing
end

function draw_HOEcollimate(filename::Maybe{AbstractString} = nothing)
function draw_HOEcollimate(filename::Union{Nothing,AbstractString} = nothing)
rect = Rectangle(5.0, 5.0, SVector(0.0, 0.0, 1.0), SVector(0.0, 0.0, 0.0))
int = HologramInterface(
SVector(0.1, -0.05, -1.0), CollimatedBeam,
Expand All @@ -188,7 +188,7 @@ function draw_HOEcollimate(filename::Maybe{AbstractString} = nothing)
return nothing
end

function draw_multiHOE(filename::Maybe{AbstractString} = nothing)
function draw_multiHOE(filename::Union{Nothing,AbstractString} = nothing)
rect = Rectangle(5.0, 5.0, SVector(0.0, 0.0, 1.0), SVector(0.0, 0.0, 0.0))
int1 = HologramInterface(
SVector(-5.0, 0.0, -20.0), ConvergingBeam,
Expand Down Expand Up @@ -220,7 +220,7 @@ function draw_multiHOE(filename::Maybe{AbstractString} = nothing)
return nothing
end

function draw_stackedbeamsplitters(filenames::MaybeVector{AbstractString} = repeat([nothing], 3))
function draw_stackedbeamsplitters(filenames::Vector{<:Union{Nothing,AbstractString}} = repeat([nothing], 3))
# ReflectOrTransmit: nondeterministic
# Transmit: deterministic, all beamsplitters transmissive
# Reflect: deterministic, all beamsplitters reflective
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Ray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function closestpointonray(r::AbstractRay{T,N}, point::SVector{N,T}) where {T,N}
end

"""
distance(r::Ray{T,N}, point::SVector{N,T}) -> Union{T,Nothing}
distance(r::Ray{T,N}, point::SVector{N,T}) -> Union{Nothing,T}
Returns distance to the position on the ray closest to point. If t < 0 returns nothing.
"""
Expand Down
10 changes: 4 additions & 6 deletions src/GlassCat/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ import SHA
import ZipFile
using Pkg

const Maybe{T} = Union{T, Nothing}

"""
add_agf(sourcefile::AbstractString; name::Maybe{AbstractString} = nothing, rebuild::Bool = true)
add_agf(sourcefile::AbstractString; name::Union{Nothing,AbstractString} = nothing, rebuild::Bool = true)
Adds an already downloaded AGF file to the sourcelist at data/sources.txt, generating the SHA256 checksum automatically.
Optionally provide a `name` for the corresponding module, and `rebuild` AGFGlassCat.jl by default.
"""
function add_agf(sourcefile::AbstractString; name::Maybe{AbstractString} = nothing, rebuild::Bool = true)
function add_agf(sourcefile::AbstractString; name::Union{Nothing,AbstractString} = nothing, rebuild::Bool = true)
if !isfile(sourcefile)
@error "AGF file not found at $sourcefile"
return
Expand Down Expand Up @@ -101,11 +99,11 @@ function verify_source(sourcefile::AbstractString, sha256sum::AbstractString)
end

"""
download_source(sourcefile::AbstractString, url::AbstractString, POST_data::Maybe{AbstractString} = nothing)
download_source(sourcefile::AbstractString, url::AbstractString, POST_data::Union{Nothing,AbstractString} = nothing)
Download and unzip an AGF glass catalog from a publicly available source. Supports POST requests.
"""
function download_source(sourcefile::AbstractString, url::AbstractString, POST_data::Maybe{AbstractString} = nothing)
function download_source(sourcefile::AbstractString, url::AbstractString, POST_data::Union{Nothing,AbstractString} = nothing)
@info "Downloading source file from $url"
try
headers = ["Content-Type" => "application/x-www-form-urlencoded"]
Expand Down
1 change: 0 additions & 1 deletion src/OpticSim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ using Revise
import GLMakie
import Makie.AbstractPlotting

include("maybe.jl")
include("constants.jl")
include("utilities.jl")

Expand Down
21 changes: 0 additions & 21 deletions src/maybe.jl

This file was deleted.

0 comments on commit 51633e3

Please sign in to comment.