From 76dd4892c584038dbf2d13c00b9676586ca97b9f Mon Sep 17 00:00:00 2001 From: Elias Carvalho <73039601+eliascarv@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:14:35 -0300 Subject: [PATCH] Fix 'Tables.subset' implementation (#74) --- src/api/tables.jl | 1 + test/runtests.jl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/api/tables.jl b/src/api/tables.jl index 689fcad..7569c41 100644 --- a/src/api/tables.jl +++ b/src/api/tables.jl @@ -15,6 +15,7 @@ end Tables.schema(geotable::AbstractGeoTable) = Tables.schema(Tables.rows(geotable)) Tables.subset(geotable::AbstractGeoTable, inds; viewhint=nothing) = SubGeoTable(geotable, inds) +Tables.subset(geotable::AbstractGeoTable, ind::Int; viewhint=nothing) = geotable[ind, :] # wrapper type for rows of the geotable table # so that we can easily inform the schema diff --git a/test/runtests.jl b/test/runtests.jl index 635343d..611ac66 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -55,9 +55,12 @@ dummymeta(domain, table) = GeoTable(domain, Dict(paramdim(domain) => table)) @test Tables.materializer(dat) <: DummyType inds = [1, 3] @test Tables.subset(dat, inds) == view(dat, inds) + @test Tables.subset(dat, 1) == (a=1, b=5, geometry=Quadrangle((0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0))) # viewhint keyword argument is ignored @test Tables.subset(dat, inds, viewhint=true) isa GeoTables.SubGeoTable @test Tables.subset(dat, inds, viewhint=false) isa GeoTables.SubGeoTable + @test Tables.subset(dat, 1, viewhint=true) isa NamedTuple + @test Tables.subset(dat, 1, viewhint=false) isa NamedTuple # dataframe interface grid = CartesianGrid(2, 2)