Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove structvarsexpr() #145

Closed
navidcy opened this issue Jan 11, 2020 · 1 comment
Closed

Remove structvarsexpr() #145

navidcy opened this issue Jan 11, 2020 · 1 comment
Assignees

Comments

@navidcy
Copy link
Member

navidcy commented Jan 11, 2020

Delete structvarsexpr()

#TODO: delete structvarsexpr() but first make sure that GeophysicalFlows.jl does not require it
"Returns an expression that defines a Composite Type of the AbstractVars variety."
function structvarsexpr(name, physfields, transfields; vardims=2, parent=:AbstractVars, T=Float64, arraytype=:Array)
physexprs = [:($fld::$arraytype{T,$vardims}) for fld in physfields]
transexprs = [:($fld::$arraytype{Complex{T},$vardims}) for fld in transfields]
expr = :(struct $name{T} <: $parent; $(physexprs...); $(transexprs...); end)
end
"""
structvarsexpr(name, fieldspecs; parent=nothing)
Returns an expression that defines a composite type whose fields are given by
the name::type pairs specifed by the tuples in fieldspecs. The convention is
name = fieldspecs[i][1] and type = fieldspecs[i][2] for the ith element of
fieldspecs.
"""
function structvarsexpr(name, fieldspecs; parent=nothing)
# name = spec[1]; type = spec[2]
# example: fieldspecs[1] = (:u, Array{Float64,2})
fieldexprs = [ :( $(spec[1])::$(spec[2]) ) for spec in fieldspecs ]
if parent == nothing
expr = :(struct $name{T}; $(fieldexprs...); end)
else
expr = :(struct $name{T} <: $parent; $(fieldexprs...); end)
end
expr
end

as soon as GeophysicalFlows.jl PR#38 is merged.

@navidcy navidcy self-assigned this Jan 11, 2020
@navidcy
Copy link
Member Author

navidcy commented Jan 19, 2020

#146 settles this issue

@navidcy navidcy closed this as completed Jan 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant