Skip to content

Commit

Permalink
fix docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
stelmo committed Jul 9, 2021
1 parent 7205fd1 commit 8972842
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
11 changes: 5 additions & 6 deletions src/base/docstrings/docstrings.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
macro _change_bound_s_bang(model_type, index_name, index_type, example, is_singular, is_inplace)
if eval(:($is_singular) != :singular)
if eval(:($is_inplace) == :inplace)
if eval(:($is_singular != :singular))
if eval(:($is_inplace == :inplace))
add_bang = "!"
descr_sentence = "Change the bounds of all reactions with `$(index_name)` in `model` in-place."
else
Expand All @@ -14,13 +14,12 @@ macro _change_bound_s_bang(model_type, index_name, index_type, example, is_singu
lbs = "fill(nothing, length($(index_name)))"
ubs = "fill(nothing, length($(index_name)))"
else
if eval(:($is_inplace) == :inplace)
if eval(:($is_inplace == :inplace))
add_bang = "!"
descr_sentence = "Change the bounds of a reaction `$(index_name)` in `model` in-place."
else
add_bang = ""
descr_sentence = "Return a shallow copy of the `model` where the bounds of reaction with
`$(index_name)` has been changed."
descr_sentence = "Return a shallow copy of the `model` where the bounds of reaction with `$(index_name)` has been changed."
end
add_s = ""
bounds1 = "lower_bound=-10, upper_bound=10"
Expand All @@ -38,7 +37,7 @@ macro _change_bound_s_bang(model_type, index_name, index_type, example, is_singu
upper_bound$($add_s) = $($ubs),
)
$($descr_sentence) Note that if the bound argument is `nothing` then it is not changed.
$($descr_sentence) Note, if the bound argument is `nothing` then it is not changed.
See also: [`change_bound`](@ref), [`change_bounds!`](@ref), [`change_bound!`](@ref), [`change_bounds!`](@ref)
Expand Down
14 changes: 7 additions & 7 deletions src/reconstruction/CoreModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ function change_bounds!(
end
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", not_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", :singular, :inplace)
function change_bound!(
model::CoreModel,
rxn::Int;
Expand All @@ -399,7 +399,7 @@ function change_bound!(
return nothing # so that nothing gets printed
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", :plural, :inplace)
function change_bounds!(
model::CoreModel,
rxn_ids::Vector{String};
Expand All @@ -409,7 +409,7 @@ function change_bounds!(
change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", not_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", :singular, :inplace)
function change_bound!(
model::CoreModel,
rxn_id::String;
Expand All @@ -419,7 +419,7 @@ function change_bound!(
change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_idxs", "Vector{Int}", "[2, 43]", :plural, :notinplace)
function change_bounds(
model::CoreModel,
rxns::Vector{Int};
Expand All @@ -436,7 +436,7 @@ function change_bounds(
return m
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", not_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_idx", "Int", "2", :singular, :notinplace)
function change_bound(
model::CoreModel,
rxn::Int;
Expand All @@ -451,7 +451,7 @@ function change_bound(
return m
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", :plural, :notinplace)
function change_bounds(
model::CoreModel,
rxn_ids::Vector{String};
Expand All @@ -461,7 +461,7 @@ function change_bounds(
change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

# @doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", not_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModel", "rxn_id", "String", "\"PFL\"", :singular, :notinplace)
function change_bound(
model::CoreModel,
rxn_id::String;
Expand Down
16 changes: 8 additions & 8 deletions src/reconstruction/CoreModelCoupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ function change_coupling_bounds!(
end
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", :plural, :inplace)
function change_bounds!(
model::CoreModelCoupled,
reaction_idxs::Vector{Int};
Expand All @@ -374,7 +374,7 @@ function change_bounds!(
end
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", not_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", :singular, :inplace)
function change_bound!(
model::CoreModelCoupled,
rxn::Int;
Expand All @@ -386,7 +386,7 @@ function change_bound!(
return nothing # so that nothing gets printed
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", :plural, :inplace)
function change_bounds!(
model::CoreModelCoupled,
rxn_ids::Vector{String};
Expand All @@ -396,7 +396,7 @@ function change_bounds!(
change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", not_plural, is_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", :singular, :inplace)
function change_bound!(
model::CoreModelCoupled,
rxn_id::String;
Expand All @@ -406,7 +406,7 @@ function change_bound!(
change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", is_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idxs", "Vector{Int}", "[2, 43]", :plural, :notinplace)
function change_bounds(
model::CoreModelCoupled,
rxns::Vector{Int};
Expand All @@ -423,7 +423,7 @@ function change_bounds(
return m
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", not_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_idx", "Int", "2", :singular, :notinplace)
function change_bound(
model::CoreModelCoupled,
reaction_idx::Int;
Expand All @@ -438,7 +438,7 @@ function change_bound(
return m
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", :plural, :notinplace)
function change_bounds(
model::CoreModelCoupled,
rxn_ids::Vector{String};
Expand All @@ -448,7 +448,7 @@ function change_bounds(
change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end

# @doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", not_plural, not_inplace)
@doc @_change_bound_s_bang("CoreModelCoupled", "rxn_id", "String", "\"PFL\"", :singular, :notinplace)
function change_bound(
model::CoreModelCoupled,
rxn_id::String;
Expand Down
8 changes: 4 additions & 4 deletions src/reconstruction/StandardModel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ remove_gene!(model, "g1")
remove_gene!(model::StandardModel, gid::String; knockout_reactions::Bool = false) =
remove_genes!(model, [gid]; knockout_reactions = knockout_reactions)

# @doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", not_plural, is_inplace)
@doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", :singular, :inplace)
function change_bound!(
model::StandardModel,
reaction_id::String;
Expand All @@ -226,7 +226,7 @@ function change_bound!(
return nothing # so that nothing gets printed
end

# @doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, is_inplace)
@doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", :plural, :inplace)
function change_bounds!(
model::StandardModel,
reaction_ids::Vector{String};
Expand All @@ -238,7 +238,7 @@ function change_bounds!(
end
end

# @doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", not_plural, not_inplace)
@doc @_change_bound_s_bang("StandardModel", "rxn_id", "String", "\"PFL\"", :singular, :notinplace)
function change_bound(
model::StandardModel,
reaction_id::String;
Expand All @@ -253,7 +253,7 @@ function change_bound(
return m
end

# @doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", is_plural, not_inplace)
@doc @_change_bound_s_bang("StandardModel", "rxn_ids", "Vector{String}", "[\"PFL\", \"FBA\"]", :plural, :notinplace)
function change_bounds(
model::StandardModel,
reaction_ids::Vector{String};
Expand Down

0 comments on commit 8972842

Please sign in to comment.