diff --git a/README.md b/README.md index 10361f106..a0a94d8b6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/core/build.jl b/src/core/build.jl index 8bc9715fc..d7f3a0ded 100644 --- a/src/core/build.jl +++ b/src/core/build.jl @@ -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]) @@ -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[] diff --git a/src/core/connections.jl b/src/core/connections.jl index b19bda5b0..f668297d9 100644 --- a/src/core/connections.jl +++ b/src/core/connections.jl @@ -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 diff --git a/src/core/defcomp.jl b/src/core/defcomp.jl index 10f53dae9..b2bc27aa2 100644 --- a/src/core/defcomp.jl +++ b/src/core/defcomp.jl @@ -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 @@ -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 diff --git a/src/core/defcomposite.jl b/src/core/defcomposite.jl index 2dfa31270..c071f6718 100644 --- a/src/core/defcomposite.jl +++ b/src/core/defcomposite.jl @@ -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)")) diff --git a/src/core/defs.jl b/src/core/defs.jl index bc7c9fa71..ae9bdd8b5 100644 --- a/src/core/defs.jl +++ b/src/core/defs.jl @@ -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.", @@ -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 diff --git a/src/core/references.jl b/src/core/references.jl index 328ebb2c3..d3b048b49 100644 --- a/src/core/references.jl +++ b/src/core/references.jl @@ -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 diff --git a/src/utils/getdataframe.jl b/src/utils/getdataframe.jl index ab399df3c..6d7d040d0 100644 --- a/src/utils/getdataframe.jl +++ b/src/utils/getdataframe.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index ac2c4e1d4..2c6a316b5 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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") diff --git a/test/test_components_ordering.jl b/test/test_components_ordering.jl index 95e055f6a..72aeca352 100644 --- a/test/test_components_ordering.jl +++ b/test/test_components_ordering.jl @@ -1,3 +1,5 @@ +module TestComponentsOrdering + using Mimi using Test @@ -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 diff --git a/test/test_composite_parameters.jl b/test/test_composite_parameters.jl index 050b7cd49..8b0f40868 100644 --- a/test/test_composite_parameters.jl +++ b/test/test_composite_parameters.jl @@ -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 \ No newline at end of file +#------------------------------------------------------------------------------ +# 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 diff --git a/test/test_num_components.jl b/test/test_num_components.jl index 5b211a924..a99fd1e39 100644 --- a/test/test_num_components.jl +++ b/test/test_num_components.jl @@ -1,3 +1,5 @@ +module TestNumComponents + using Test using Mimi @@ -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