Skip to content

Commit

Permalink
Fix connection in test see #25
Browse files Browse the repository at this point in the history
  • Loading branch information
danlooo committed Jan 15, 2024
1 parent e870dab commit 623e8e4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/Cubes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ function binary_operator(cube1::DataCube, cube2::DataCube, openeo_process::Strin
end

function reduce_dimension(cube::DataCube, openeo_process::String, dimension::String)
Symbol(openeo_process) in keys(cube.connection.processes) || error("Reducer name not found on backend")
Symbol(openeo_process) in keys(cube.connection.processes) || error("Reducer process not found on backend")
Symbol(dimension) in keys(cube.collection[Symbol("cube:dimensions")]) || error("Dimension not found")

call = ProcessCall("reduce_dimension", Dict(
Expand Down Expand Up @@ -310,10 +310,7 @@ broadcasted(::typeof(!), cube::DataCube) = unary_operator(cube, "not")

# reduce operations
function reduce(op::Process, cube::DataCube; dims::String)
if !(op.parameters[1].name == "data" && op.parameters[2].name == "ignore_nodata")
error("Process eligible to reduce must only contain parameters data and ignore_nodata.")
end

("data" in op.parameters .|> x -> x.name) || error("Process must have argument data.")
dims in cube.dimensions || error("Dimension $dims not present in the data cube.")

reduce_dimension(cube::DataCube, op.id, dims)
Expand Down
6 changes: 3 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ password = ENV["OPENEO_PASSWORD"]
@test reduce_dimension(cube["B02"], "min", "t") |> typeof == DataCube
@test reduce_dimension(cube, "min", "t") |> typeof == DataCube

@test reduce(con.max, cube["B01"], dims="t") |> typeof == DataCube
@test maximum(cube["B01"], dims="t") |> typeof == DataCube
@test reduce(con.max, cube["B01"], dims="t") |> typeof == DataCube
@test_throws ErrorException maximum(cube["B01"], dims="xx")
@test reduce(cube.connection.max, cube["B01"], dims="t") |> typeof == DataCube
@test_throws ErrorException maximum(cube["B01"], dims="xx")
@test_throws ErrorException reduce(cube.connection.sin, cube, dims="t")

@test cube.dimensions == ["x", "y", "t", "bands"]
@test cube["B01"].dimensions == ["x", "y", "t"]
Expand Down

0 comments on commit 623e8e4

Please sign in to comment.