Skip to content

Commit

Permalink
ADD: Warning when fields are missing during PTI parse (#294)
Browse files Browse the repository at this point in the history
Adds a warning enumerating the missing data fields when parsing a PTI
file.
  • Loading branch information
pseudocubic authored and ccoffrin committed May 30, 2018
1 parent 8290d63 commit fba2073
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/io/pti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,15 @@ data types given by `section` and saved into `data::Dict`
"""
function parse_line_element!(data::Dict, elements::Array, section::AbstractString)
missing = []
for (field, dtype) in get_pti_dtypes(section)
try
element = shift!(elements)
catch message
if isa(message, ArgumentError)
debug(LOGGER, "Have run out of elements in $section at $field")
break
push!(missing, field)
continue
end
end

Expand Down Expand Up @@ -282,6 +284,11 @@ function parse_line_element!(data::Dict, elements::Array, section::AbstractStrin
end
end
end

if length(missing) > 0
missing_str = join(missing, ", ")
warn(LOGGER, "The following fields in $section are missing: $missing_str")
end
end


Expand Down
5 changes: 4 additions & 1 deletion test/psse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,10 @@ end
@test_warn(TESTLOG, "Could not find bus 1, returning 0 for field vm",
PowerModels.get_bus_value(1, "vm", dummy_data))

@test_warn(getlogger(PowerModels), "PTI v33.0.0 does not contain vmin and vmax values, defaults of 0.9 and 1.1, respectively, assumed.",
@test_warn(TESTLOG, "PTI v33.0.0 does not contain vmin and vmax values, defaults of 0.9 and 1.1, respectively, assumed.",
PowerModels.parse_file("../test/data/pti/parser_test_i.raw"))

@test_warn(TESTLOG, "The following fields in BUS are missing: NVHI, NVLO, EVHI, EVLO",
PowerModels.parse_file("../test/data/pti/parser_test_i.raw"))

setlevel!(TESTLOG, "error")
Expand Down

0 comments on commit fba2073

Please sign in to comment.