-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix error when setting outplanting levels due to latest RME expecting density as vector #29
Conversation
If version< 1.0.28 then expect Int, if not expect vector
src/deployment.jl
Outdated
function version_check()::Vector{Int64} | ||
rme_ver = @RME version()::Cstring | ||
return parse.(Int64, split(rme_ver, '.')) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have an issue with the function name in that it doesn't perform a "check".
To me, it should be rme_version()
or similar as it simply returns the version number (albeit separated).
Simply version_check
can be confusing. It's unclear at first glance: What does it mean? Version of the Julia package?
I'm also hesitant to accept it returning a vector of integers. Version numbers should be treated as IDs firstly.
I also dislike how this is being used. Remember that if you're hardcoding index values, then it's usually a smell telling you there's a better way.
In this case, I would prefer:
- a named tuple be returned:
(major=1, minor=0, patch=28)
(following SemVer) - the function name be changed to
rme_version_info()
src/deployment.jl
Outdated
Set outplanting deployments across a range of years, automatically determining the | ||
coral deployment density to maintain the set grid size. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No indent for main text in docstrings
src/deployment.jl
Outdated
req_area = area_needed(max_n_corals, density) | ||
|
||
# Divide by half (i.e., `* 0.5`) as RME simulates two deployments per year | ||
mod_density = (n_corals * 0.5) / (req_area / m2_TO_km2) | ||
deployment_area_pct = min((req_area / sum(target_areas)) * 100.0, 100.0) | ||
mod_density = (n_corals * 0.5) ./ (req_area ./ m2_TO_km2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this line a duplication of area_needed()
?
src/deployment.jl
Outdated
mod_density = (n_corals * 0.5) / (req_area / m2_TO_km2) | ||
deployment_area_pct = min((req_area / sum(target_areas)) * 100.0, 100.0) | ||
mod_density = (n_corals * 0.5) ./ (req_area ./ m2_TO_km2) | ||
deployment_area_pct = min((sum(req_area) / sum(target_areas)) * 100.0, 100.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calculate sum(req_area)
once beforehand and replace the repeated sum()
here and below please.
src/deployment.jl
Outdated
deployment_area_pct = min((req_area / sum(target_areas)) * 100.0, 100.0) | ||
|
||
# In RME versions higher than 1.0.28 density needs to be a vector with each element representing density per species | ||
version_vec = version_check() | ||
density = (version_vec[3] <= 28) && (version_vec[1] == 1) ? density : fill(density, 6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ignoring the hardcoded indexing here, think about what would happen if the RME version advances to v1.2.28
src/deployment.jl
Outdated
@@ -130,15 +156,30 @@ function set_outplant_deployment!( | |||
last_year::Int64, | |||
year_step::Int64, | |||
area_km2::Vector{Float64}, | |||
density::Float64 | |||
density::Vector{Float64} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this break backward compatibility?
docs/src/getting_started.md
Outdated
# Add 3 DHW enhancement to outplanted corals | ||
set_option("restoration_dhw_tolerance_outplants", 3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify why the outplanting is removed in the example?
The commit message for this change just says "fix docs"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restoration_dhw_tolerance_outplants
was removed in version 1.0.31
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we dropping backwards compatibility?
Check update to include major, minor and patch
Define sum(area_req) as variable to avoid multiple summations Fix docs
26f3418
to
b1d80d0
Compare
I believe I've addressed your comments @ConnectedSystems |
rme_ver = @RME version()::Cstring | ||
rme_ver = parse.(Int64, split(rme_ver, '.')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No change required here, just noting this is type unstable (going from string to vector of ints) so might need an adjustment later.
src/deployment.jl
Outdated
- `density` : Stocking density per m². In RME versions higher than 1.0.28 density needs to be a vector | ||
with each element representing density per species |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `density` : Stocking density per m². In RME versions higher than 1.0.28 density needs to be a vector | |
with each element representing density per species | |
- `density` : Stocking density per m². In RME versions higher than v1.0.28, density is expected to be a vector | |
with each element representing the density per functional group |
src/deployment.jl
Outdated
@RME ivSetOutplantCountPerM2(name::Cstring, mod_density::Cdouble)::Cint | ||
|
||
rme_version = rme_version_info() | ||
if !((rme_version.patch <= 28) && (rme_version.minor == 0) && (rme_version.major == 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reorder to be in logical order please: major, minor, patch.
I've addressed your comments @ConnectedSystems, let me know if there are others |
@Rosejoycrocker there's still the question of what to do with the example currently in the docs. It would be best to show how to do intervention runs with the most recent version of RME we have at the very least, with a note on how to do it with older versions. |
I'll add the removed example as a comment with a note about the version |
…was removed in v1.0.31" This reverts commit a42a1c6.
# Adding dhw tolerance was removed in v1.0.31 | ||
# Add 3 DHW enhancement to outplanted corals | ||
# set_option("restoration_dhw_tolerance_outplants", 3) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to demonstrate what to do with versions > v1.0.31
From the docs and matlab files it looks like they added an rme_iv_set_outplant_heat_tolerance
function.
The relevant RME functions are:
ivSetOutplantHeatToleranceMeanDhw
and ivSetOutplantHeatToleranceSdDhw
Both of which expect a vector of values for each functional group.
Actually, I'm going to accept and merge this as is and address the above later.
Resolves #28