Skip to content

Commit fba2073

Browse files
pseudocubicccoffrin
authored andcommitted
ADD: Warning when fields are missing during PTI parse (#294)
Adds a warning enumerating the missing data fields when parsing a PTI file.
1 parent 8290d63 commit fba2073

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/io/pti.jl

+8-1
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,15 @@ data types given by `section` and saved into `data::Dict`
247247
248248
"""
249249
function parse_line_element!(data::Dict, elements::Array, section::AbstractString)
250+
missing = []
250251
for (field, dtype) in get_pti_dtypes(section)
251252
try
252253
element = shift!(elements)
253254
catch message
254255
if isa(message, ArgumentError)
255256
debug(LOGGER, "Have run out of elements in $section at $field")
256-
break
257+
push!(missing, field)
258+
continue
257259
end
258260
end
259261

@@ -282,6 +284,11 @@ function parse_line_element!(data::Dict, elements::Array, section::AbstractStrin
282284
end
283285
end
284286
end
287+
288+
if length(missing) > 0
289+
missing_str = join(missing, ", ")
290+
warn(LOGGER, "The following fields in $section are missing: $missing_str")
291+
end
285292
end
286293

287294

test/psse.jl

+4-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ end
184184
@test_warn(TESTLOG, "Could not find bus 1, returning 0 for field vm",
185185
PowerModels.get_bus_value(1, "vm", dummy_data))
186186

187-
@test_warn(getlogger(PowerModels), "PTI v33.0.0 does not contain vmin and vmax values, defaults of 0.9 and 1.1, respectively, assumed.",
187+
@test_warn(TESTLOG, "PTI v33.0.0 does not contain vmin and vmax values, defaults of 0.9 and 1.1, respectively, assumed.",
188+
PowerModels.parse_file("../test/data/pti/parser_test_i.raw"))
189+
190+
@test_warn(TESTLOG, "The following fields in BUS are missing: NVHI, NVLO, EVHI, EVLO",
188191
PowerModels.parse_file("../test/data/pti/parser_test_i.raw"))
189192

190193
setlevel!(TESTLOG, "error")

0 commit comments

Comments
 (0)