Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/core/defcomp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ macro defcomp(comp_name, ex)

# DEPRECATION - EVENTUALLY REMOVE
if @capture(elt, name_::datum_type_ = elt_type_(args__))
msg = "The following syntax has been deprecated in @defcomp: \"$name::$datum_type = $elt_type(...)\". Use curly bracket syntax instead: \"$name = $elt_type{$datum_type}(...)\""
error("$msg\n$(reduce((x,y) -> "$x\n$y", stacktrace()))")
error("The following syntax has been deprecated in @defcomp: \"$name::$datum_type = $elt_type(...)\". Use curly bracket syntax instead: \"$name = $elt_type{$datum_type}(...)\"")
elseif ! @capture(elt, name_ = (elt_type_{datum_type_}(args__) | elt_type_(args__)))
end

Expand Down
10 changes: 2 additions & 8 deletions src/core/model.jl
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ new component specified by `comp_id`. Use the following syntax instead:
See docstring for `replace!` for further description of available functionality.
"""
function replace_comp!(m::Model, comp_id::ComponentId, comp_name::Symbol=comp_id.comp_name; kwargs...)
msg = "Function `replace_comp!(m, comp_id, comp_name; kwargs...)` has been deprecated. Use `replace!(m, comp_name => Mimi.compdef(comp_id); kwargs...)` instead."
st = _get_stacktrace_string()
full_msg = string(msg, " \n", st)
error(full_msg)
error("Function `replace_comp!(m, comp_id, comp_name; kwargs...)` has been deprecated. Use `replace!(m, comp_name => Mimi.compdef(comp_id); kwargs...)` instead.")
end

# DEPRECATION - EVENTUALLY REMOVE
Expand All @@ -194,10 +191,7 @@ new component specified by `comp_def`. Use the following syntax instead:
See docstring for `replace!` for further description of available functionality.
"""
function replace_comp!(m::Model, comp_def::ComponentDef, comp_name::Symbol=comp_def.comp_id.comp_name; kwargs...)
msg = "Function `replace_comp!(m, comp_def, comp_name; kwargs...)` has been deprecated. Use `replace!(m, comp_name => comp_def; kwargs...)` instead."
st = _get_stacktrace_string()
full_msg = string(msg, " \n", st)
error(full_msg)
error("Function `replace_comp!(m, comp_def, comp_name; kwargs...)` has been deprecated. Use `replace!(m, comp_name => comp_def; kwargs...)` instead.")
end

"""
Expand Down
4 changes: 2 additions & 2 deletions src/core/time.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ end
Deprecated fucntion to return true or false, true if the current time (year) for `ts` is `t`
"""
function is_time(ts::AbstractTimestep, t::Int)
error("`is_time(ts, t)` is deprecated. Use comparison operators with TimestepValue objects instead: `ts == TimestepValue(t)` \n$(stacktrace())", :is_time)
error("`is_time(ts, t)` is deprecated. Use comparison operators with TimestepValue objects instead: `ts == TimestepValue(t)`")
end

"""
Expand All @@ -46,7 +46,7 @@ end
Deprecated function to return true or false, true if `ts` timestep is step `t`.
"""
function is_timestep(ts::AbstractTimestep, t::Int)
error("`is_timestep(ts, t)` is deprecated. Use comparison operators with TimestepIndex objects instead: `ts == TimestepIndex(t)` \n$(stacktrace())", :is_timestep)
error("`is_timestep(ts, t)` is deprecated. Use comparison operators with TimestepIndex objects instead: `ts == TimestepIndex(t)`")
end

"""
Expand Down
24 changes: 2 additions & 22 deletions src/core/time_arrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,36 +57,16 @@ function _single_index_check(data, idxs)
end
end

# DEPRECATION - EVENTUALLY REMOVE
# Helper to print stacktrace for the integer indexing errors
function _get_stacktrace_string()
s = ""
for line in stacktrace()
if startswith(string(line), "run_timestep")
return s
else
s = string(s, line, "\n")
end
end
return s
end

# DEPRECATION - EVENTUALLY REMOVE
# Helper function for getindex; throws an error if one indexes into a TimestepArray with an integer
function _throw_int_getindex_error()
msg = "Indexing with getindex into a TimestepArray with Integer(s) is deprecated, please index with a TimestepIndex(index::Int) instead ie. instead of t[2] use t[TimestepIndex(2)]\n"
st = _get_stacktrace_string()
full_msg = string(msg, " \n", st)
error(full_msg)
error("Indexing with getindex into a TimestepArray with Integer(s) is deprecated, please index with a TimestepIndex(index::Int) instead ie. instead of t[2] use t[TimestepIndex(2)]")
end

# DEPRECATION - EVENTUALLY REMOVE
# Helper function for setindex; throws an error if one indexes into a TimestepArray with an integer
function _throw_int_setindex_error()
msg = "Indexing with setindex into a TimestepArray with Integer(s) is deprecated, please index with a TimestepIndex(index::Int) instead ie. instead of t[2] use t[TimestepIndex(2)]"
st = _get_stacktrace_string()
full_msg = string(msg, " \n", st)
error(full_msg)
error("Indexing with setindex into a TimestepArray with Integer(s) is deprecated, please index with a TimestepIndex(index::Int) instead ie. instead of t[2] use t[TimestepIndex(2)]")
end

# Helper macro used by connector
Expand Down
4 changes: 1 addition & 3 deletions src/mcs/mcs_types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,5 @@ function getdataframe(sim_inst::SimulationInstance, comp_name::Symbol, datum_nam
end

function Base.getindex(sim_inst::SimulationInstance, comp_name::Symbol, datum_name::Symbol; model::Int = 1)
msg = "getindex method for `SimulationInstance` has been replaced with getdataframe function for consistency of return type, please use getdataframe instead"
Base.depwarn("$msg, $(stacktrace())", :getindex)
return sim_inst.results[model][(comp_name, datum_name)]
error("getindex method for `SimulationInstance` has been replaced with getdataframe function for consistency of return type, please use getdataframe instead")
end