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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In addition please do not hesitate to ask any questions on the forum, we are wor
## Contributions and Questions

You can interact with the Mimi development team via issues and pull requests here on github, and in the [Mimi Framework forum](https://forum.mimiframework.org). Contributions to Mimi are also most welcome, and
please get in touch with [David Anthoff](http://www.david-anthoff.com) if you are want to be involved in any way with this effort.
please get in touch with [David Anthoff](http://www.david-anthoff.com) if you want to be involved in any way with this effort.

## Acknowledgements

Expand Down
6 changes: 3 additions & 3 deletions src/core/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ function _get_leaf_level_ipcs(md::ModelDef, conn::InternalParameterConnection)

top_dst_path = conn.dst_comp_path
comp = find_comp(md, top_dst_path)
comp !== nothing || error("Can't find $(top_dst_path) from $(md.comp_id)")
comp !== nothing || error("Cannot find $(top_dst_path) from $(md.comp_id)")
par_sub_paths, param_names = _find_paths_and_names(comp, conn.dst_par_name)
param_paths = [ComponentPath(top_dst_path, sub_path) for sub_path in par_sub_paths]

top_src_path = conn.src_comp_path
comp = find_comp(md, top_src_path)
comp !== nothing || error("Can't find $(top_src_path) from $(md.comp_id)")
comp !== nothing || error("Cannot find $(top_src_path) from $(md.comp_id)")
var_sub_path, var_name = _find_paths_and_names(comp, conn.src_var_name)
var_path = ComponentPath(top_src_path, var_sub_path[1])

Expand All @@ -161,7 +161,7 @@ that need to be made under the hood as specified by `epc`.
function _get_leaf_level_epcs(md::ModelDef, epc::ExternalParameterConnection)

comp = find_comp(md, epc.comp_path)
comp !== nothing || error("Can't find $(epc.comp_path) from $(md.comp_id)")
comp !== nothing || error("Cannot find $(epc.comp_path) from $(md.comp_id)")
par_sub_paths, param_names = _find_paths_and_names(comp, epc.param_name)

leaf_epcs = ExternalParameterConnection[]
Expand Down
2 changes: 1 addition & 1 deletion src/core/connections.jl
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ Split a string of the form "/path/to/component:datum_name" into the component pa
"""
function split_datum_path(obj::AbstractCompositeComponentDef, s::AbstractString)
elts = split(s, ":")
length(elts) != 2 && error("Can't split datum path '$s' into ComponentPath and datum name")
length(elts) != 2 && error("Cannot split datum path '$s' into ComponentPath and datum name")
return (ComponentPath(obj, elts[1]), Symbol(elts[2]))
end

Expand Down
4 changes: 2 additions & 2 deletions src/core/defcomp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ is_builtin(comp_name) = comp_name in built_in_comps

function _generate_run_func(comp_name, module_name, args, body)
if length(args) != 4
error("Can't generate run_timestep; requires 4 arguments but got $args")
error("Cannot generate run_timestep; requires 4 arguments but got $args")
end

(p, v, d, t) = args
Expand All @@ -36,7 +36,7 @@ end
function _generate_init_func(comp_name, module_name, args, body)

if length(args) != 3
error("Can't generate init function; requires 3 arguments but got $args")
error("Cannot generate init function; requires 3 arguments but got $args")
end

# add types to the parameters
Expand Down
2 changes: 1 addition & 1 deletion src/core/defcomposite.jl
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ Import a variable from the given subcomponent
function _import_var!(obj::AbstractCompositeComponentDef, localname::Symbol,
path::ComponentPath, vname::Symbol)
if haskey(obj, localname)
error("Can't import variable; :$localname already exists in component $(obj.comp_id)")
error("Cannot import variable; :$localname already exists in component $(obj.comp_id)")
end

comp = @or(find_comp(obj, path), error("$path not found from component $(obj.comp_id)"))
Expand Down
4 changes: 2 additions & 2 deletions src/core/defs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ end

function set_param!(md::ModelDef, comp_def::AbstractComponentDef, param_name::Symbol, ext_param_name::Symbol, value; dims=nothing)
has_parameter(comp_def, param_name) ||
error("Can't find parameter :$param_name in component $(pathof(comp_def))")
error("Cannot find parameter :$param_name in component $(pathof(comp_def))")

if has_parameter(md, ext_param_name)
error("Cannot set parameter :$ext_param_name, the model already has an external parameter with this name.",
Expand Down Expand Up @@ -531,7 +531,7 @@ function set_param!(md::ModelDef, param_name::Symbol, value; dims=nothing, ignor
end

if isempty(comps)
error("Can't set parameter :$param_name; not found in ModelDef or children")
error("Cannot set parameter :$param_name; not found in ModelDef or children")
end

# which fields to check for collisions in subcomponents
Expand Down
2 changes: 1 addition & 1 deletion src/core/references.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end
Connect two components as `comp_ref[var_name] = var_ref`.
"""
function Base.setindex!(comp_ref::ComponentReference, var_ref::VariableReference, vname::Symbol)
_same_composite(comp_ref, var_ref) || error("Can't connect variables defined in different composite trees")
_same_composite(comp_ref, var_ref) || error("Cannot connect variables defined in different composite trees")

_connect_param!(parent(comp_ref), pathof(comp_ref), vname, pathof(var_ref), var_name(var_ref))
end
2 changes: 1 addition & 1 deletion src/utils/getdataframe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function getdataframe(m::AbstractModel, pairs::Pair{Symbol, Symbol}...)
for (comp_name, item_name) in pairs[2:end]
next_dims = dim_names(m, comp_name, item_name)
if dims != next_dims
error("Can't create DataFrame from items with different dimensions ($comp_name1.$item_name1: $dims vs $comp_name.$item_name: $next_dims)")
error("Cannot create DataFrame from items with different dimensions ($comp_name1.$item_name1: $dims vs $comp_name.$item_name: $next_dims)")
end
result = getdataframe(m, comp_name, item_name)
df = hcat(df, result[!, [item_name]]) # [[xx]] retrieves a 1 column DataFrame
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Electron.prep_test_env()
@info("test_timesteparrays.jl")
@time include("test_timesteparrays.jl")

@info("test_dimensions")
@info("test_dimensions.jl")
@time include("test_dimensions.jl")

@info("test_datum_storage.jl")
Expand Down
4 changes: 4 additions & 0 deletions test/test_components_ordering.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestComponentsOrdering

using Mimi
using Test

Expand Down Expand Up @@ -43,3 +45,5 @@ addcomponent(my_model, testcomp1)
@test_throws ErrorException addcomponent(my_model, testcomp2, before=:testcomp3)

@test_throws ErrorException addcomponent(my_model, testcomp2, after=:testcomp3)

end #module
9 changes: 8 additions & 1 deletion test/test_composite_parameters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,11 @@ run(m3)
@test length(keys(m3.md.external_params)) == 4 # The default value was not added to the original md's list
@test length(keys(m3.mi.md.external_params)) == 5 # Only added to the model instance's definition

end
#------------------------------------------------------------------------------
# Test set_param! for parameter that exists in neither model definition nor any subcomponent

m1 = get_model()
err8 = try set_param!(m1, :pDNE, 42) catch err err end
@test occursin("not found in ModelDef or children", sprint(showerror, err8))

end #module
4 changes: 4 additions & 0 deletions test/test_num_components.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
module TestNumComponents

using Test
using Mimi

Expand All @@ -15,3 +17,5 @@ m = Model()
# trying to run model with no components
set_dimension!(m, :time, 1:10)
@test_throws ErrorException run(m)

end #module