Skip to content

Commit

Permalink
NamedDimension test code
Browse files Browse the repository at this point in the history
See PALEOtoolkit/PALEOmodel.jl#48

Initial test updating NamedDimension so that `coords` is just
a vector of names of preferred coordinates.

NB: shows that there are no tests for get_region in this package.
  • Loading branch information
sjdaines committed May 4, 2023
1 parent 6ecff07 commit 759a0b8
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/CoordsDims.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,23 +119,24 @@ end
"""
NamedDimension
A named dimension, with optional attached fixed coordinates `coords`
A named dimension, with optional preferred coordinates `coords`
PALEO convention is that where possible `coords` contains three elements, for cell
midpoints, lower edges, upper edges, in that order.
"""
mutable struct NamedDimension
name::String
size::Int64
coords::Vector{FixedCoord} # may be empty
coords::Vector{String} # may be empty
end

if false
"create from size only (no coords)"
function NamedDimension(name, size::Integer)
function NamedDimension(name, size::Integer, coords=String[])
return NamedDimension(
name,
size,
FixedCoord[],
String[],
)
end

Expand Down Expand Up @@ -191,9 +192,9 @@ function build_coords_edges(nd::NamedDimension)
end
end

end

function Base.show(io::IO, nd::NamedDimension)
print(io, "NamedDimension(name=", nd.name, ", size=", nd.size, ", coords=(")
join(io, [c.name for c in nd.coords], ", ")
print(io, "))")
print(io, "NamedDimension(name=", nd.name, ", size=", nd.size, ", coords=", nd.coords, ")")
return nothing
end

0 comments on commit 759a0b8

Please sign in to comment.