lanl-ansi/PowerModelsDistribution.jl

[BUG] Joining lines calls a function which throws an error

hei06j opened this issue · 2 comments

In the network reduction by joining lines, the line 1338 with link below will throw an error if comp["bus"] in line 1334 is not a string, as it attempts to append an integer to a vector of strings.

append!(buses_exclude, buses)

buses = isa(comp["bus"], String) ? [comp["bus"]] : comp["bus"]

error:

ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type String

I assume replacing the last argument in line 1334 with [string(comp["bus"])] would fix the problem.

I actually think that the correct way to fix this is to rewrite the line to check if isa(comp["bus"], Vector).

That said, I'm not clear on how we would end up with non-string bus names, could you provide a small example so that we can add a unit test?

Actually you are correct. I encountered this error when I used the join_line code (with necessary modifications) to reduce a network in PowerModels.jl rather than PMD.jl. So given that this code works with data_eng and all assets have the key "bus" as string, my original bug is not valid here. Thanks so much for the clarification and I am happy for the issue to be closed if you want to.