Skip to content

Commit

Permalink
more checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vlandau committed Jan 30, 2024
1 parent e41d3f2 commit df6dc0b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/errors_warnings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function missing_args_error(missing_args)
@error "The following arguments are missing from your .ini (or config Dictionary) with no defaults:
$(join(map(string, missing_args), " "))"
end

function check_raster_alignment(raster1, raster2, name1, name2, allow_different_projections)
sizes_not_equal = size(raster1[1]) != size(raster2[1])
projections_not_equal = (raster1[2] != raster2[2]) || (raster1[3] != raster2[3])
Expand Down Expand Up @@ -106,8 +107,7 @@ function check_arg_values(
cfg::Dict{String, String},
reclass_table::Union{Nothing, MissingArray{T, 2} where T <: Number},
condition1::Union{Nothing, MissingArray{T, 2} where T <: Number},
condition2::Union{Nothing, MissingArray{T, 2} where T <: Number},
write_outputs::Bool
condition2::Union{Nothing, MissingArray{T, 2} where T <: Number}
)
# Case when reclass_table is specified but reclass is false
if (cfg["reclassify_resistance"] TRUELIST) && (reclass_table !== nothing)
Expand Down
16 changes: 14 additions & 2 deletions src/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function run_omniscape(
cfg_user = cfg

# Check for unsupported or missing arguments
check_arg_values(cfg, reclass_table, condition1, condition2, write_outputs)
check_arg_values(cfg, reclass_table, condition1, condition2)
check_unsupported_args(cfg)
check_missing_args_dict(cfg_user) && return

Expand Down Expand Up @@ -482,7 +482,7 @@ function run_omniscape(path::String)
"resistance_file", "condition1_file",
allow_different_projections) && return

# get rid of unneedecheck_rasterd raster to save memory
# get rid of unneeded raster to save memory
condition1_raster = nothing

if compare_to_future == "1" || compare_to_future == "both"
Expand All @@ -497,6 +497,9 @@ function run_omniscape(path::String)
# get rid of unneeded raster to save memory
condition1_future_raster = nothing
else
if cfg["condition1_future_file"] != ""
@error("You provided a future condition raster (condition1_future_file), but did not specify compare_to_future in your INI. compare_to_future must be \"1\" or \"both\" in order to compare to future conditions.")

Check warning on line 501 in src/main.jl

View check run for this annotation

Codecov / codecov/patch

src/main.jl#L501

Added line #L501 was not covered by tests
end
condition1_future = nothing
end

Expand Down Expand Up @@ -524,14 +527,23 @@ function run_omniscape(path::String)
# get rid of unneeded raster to save memory
condition2_future_raster = nothing
else
if cfg["condition2_future_file"] != ""
@error("You provided a future condition raster (condition2_future_file), but did not specify compare_to_future in your INI. compare_to_future must be \"2\" or \"both\" in order to compare to future conditions.")

Check warning on line 531 in src/main.jl

View check run for this annotation

Codecov / codecov/patch

src/main.jl#L531

Added line #L531 was not covered by tests
end
condition2_future = nothing
end

else
if cfg["condition2_file"] != ""
@error("You provided a condition2_file, but n_conditions was not set to 2 in your INI file. Set n_conditions to 2 if you wish to use a second condition for calculating conditional connectivity.")

Check warning on line 538 in src/main.jl

View check run for this annotation

Codecov / codecov/patch

src/main.jl#L538

Added line #L538 was not covered by tests
end
condition2 = nothing
condition2_future = condition2
end
else
if (cfg["condition2_file"] != "") || (cfg["condition1_file"] != "")
@error("conditional is set to false in your INI but you provided file paths to condition files. Please set conditional to true if you wish to compute conditional connectivity.")

Check warning on line 545 in src/main.jl

View check run for this annotation

Codecov / codecov/patch

src/main.jl#L545

Added line #L545 was not covered by tests
end
condition1 = nothing
condition2 = nothing
condition1_future = condition1
Expand Down

0 comments on commit df6dc0b

Please sign in to comment.