Skip to content

Commit

Permalink
Expose only AbstractVector{Float64} via BMI (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
SouthEndMusic authored Apr 9, 2024
1 parent ef7b43e commit 71f43cb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/bmi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function BMI.update_until(model::Model, time)::Model
return model
end

function BMI.get_value_ptr(model::Model, name::AbstractString)
function BMI.get_value_ptr(model::Model, name::AbstractString)::AbstractVector{Float64}
if name == "basin.storage"
model.integrator.u.storage
elseif name == "basin.level"
Expand All @@ -47,7 +47,7 @@ function BMI.get_value_ptr(model::Model, name::AbstractString)
elseif name == "basin.subgrid_level"
model.integrator.p.subgrid.level
elseif name == "user_demand.demand"
model.integrator.p.user_demand.demand
vec(model.integrator.p.user_demand.demand)
elseif name == "user_demand.realized"
model.integrator.p.user_demand.realized_bmi
else
Expand Down
2 changes: 1 addition & 1 deletion core/test/bmi_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ end
BMI.update_until(model, 86400.0)
value_second = BMI.get_value_ptr(model, name)
# get_value_ptr does not copy
@test value_first === value_second
@test value_first === value_second || pointer(value_first) == pointer(value_second)
end
end

Expand Down

0 comments on commit 71f43cb

Please sign in to comment.