Skip to content

Commit

Permalink
Print available identifiers with a for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
juliohm committed Jan 5, 2017
1 parent 59f0c27 commit 1aa580b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Usage
```julia
TI = training_image(identifier::AbstractString)
```
where `identifier` can be any of the strings listed with the command `GeoStatsImages.available`
where `identifier` can be any of the strings listed with the command `GeoStatsImages.available()`

Preview
-------
Expand Down
12 changes: 9 additions & 3 deletions src/database.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@
## ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
## OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

datadir = joinpath(Pkg.dir(),"GeoStatsImages","src","data")
datadir = joinpath(Pkg.dir("GeoStatsImages"),"src","data")
datafiles = filter(s -> ismatch(r".*\.dat", s), readdir(datadir))

database = Dict()
for fname in datafiles
push!(database, fname[1:end-4] => joinpath(datadir, fname))
end

available = sort(collect(keys(database)))
identifiers = sort(collect(keys(database)))

function available()
for identifier in identifiers
println(identifier)
end
end

function training_image(identifier::AbstractString)
@assert identifier available "training image not available"
@assert identifier identifiers "training image not available"

datafile = database[identifier]

Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ using Base.Test

@testset "Basic checks" begin
# all available images loaded as arrays
for identifier in GeoStatsImages.available
for identifier in GeoStatsImages.identifiers
@test isa(training_image(identifier), AbstractArray)
end

Expand Down

0 comments on commit 1aa580b

Please sign in to comment.