Skip to content
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

bug: get_cost_pair should throw an error or return empty or a more informative error #1180

Open
pesap opened this issue Aug 27, 2024 · 0 comments
Assignees
Labels

Comments

@pesap
Copy link
Member

pesap commented Aug 27, 2024

This happens because this function fails when the vals object is empty

  last_increasing_point = findfirst(x -> x < 0.0, [diff(getfield.(vals, :x))..., -Inf])

Stack trace

ERROR: BoundsError: attempt to access 0-element Vector{Any} at index [1:1]
Stacktrace:
  [1] throw_boundserror(A::Vector{Any}, I::Tuple{UnitRange{Int64}})
    @ Base ./abstractarray.jl:737
  [2] checkbounds
    @ ./abstractarray.jl:702 [inlined]
  [3] getindex(A::Vector{Any}, I::UnitRange{Int64})
    @ Base ./array.jl:973
  [4] get_cost_pairs(gen::@NamedTuple{}, cost_colnames::PowerSystems._HeatRateColumns)
    @ PowerSystems ~/dev/Sienna/PowerSystems.jl/src/parsers/power_system_table_data.jl:948
  [5] make_cost(::Type{…}, data::PowerSystemTableData, gen::@NamedTuple{}, cost_colnames::PowerSystems._HeatRateColumns)
    @ PowerSystems ~/dev/Sienna/PowerSystems.jl/src/parsers/power_system_table_data.jl:833
  [6] make_thermal_generator(data::PowerSystemTableData, gen::@NamedTuple{}, cost_colnames::PowerSystems._HeatRateColumns, bus::ACBus)
    @ PowerSystems ~/dev/Sienna/PowerSystems.jl/src/parsers/power_system_table_data.jl:1132
  [7] make_generator(data::PowerSystemTableData, gen::@NamedTuple{}, cost_colnames::PowerSystems._HeatRateColumns, bus::ACBus, gen_storage::Tuple{…})
    @ PowerSystems ~/dev/Sienna/PowerSystems.jl/src/parsers/power_system_table_data.jl:796
  [8] gen_csv_parser!(sys::System, data::PowerSystemTableData)
    @ PowerSystems ~/dev/Sienna/PowerSystems.jl/src/parsers/power_system_table_data.jl:563
  [9] System(data::PowerSystemTableData; time_series_resolution::Nothing, time_series_in_memory::Bool, time_series_directory::Nothing, runchecks::Bool, kwargs::@Kwargs{})
    @ PowerSystems ~/dev/Sienna/PowerSystems.jl/src/parsers/power_system_table_data.jl:279
 [10] top-level scope
    @ REPL[11]:1
Some type information was truncated. Use `show(err)` to see complete types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants