diff --git a/Project.toml b/Project.toml index 93091014..02b34ac5 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DynamicExpressions" uuid = "a40a106e-89c9-4ca8-8020-a735e8728b6b" authors = ["MilesCranmer "] -version = "1.4.1" +version = "1.5.0" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/Interfaces.jl b/src/Interfaces.jl index 346db23d..2875ef65 100644 --- a/src/Interfaces.jl +++ b/src/Interfaces.jl @@ -123,7 +123,9 @@ function _check_set_constants!(ex::AbstractExpression) return first(get_scalar_constants(ex)) ≈ x2 end function _check_string_tree(ex::AbstractExpression) - return string_tree(ex) isa AbstractString + return string_tree(ex) isa AbstractString && + string_tree(ex; pretty=false) isa AbstractString && + string_tree(ex; pretty=true) isa AbstractString end function _check_default_node(ex::AbstractExpression{T}) where {T} ET = typeof(ex) diff --git a/src/ParametricExpression.jl b/src/ParametricExpression.jl index 0eb5db04..7f0ae660 100644 --- a/src/ParametricExpression.jl +++ b/src/ParametricExpression.jl @@ -360,7 +360,6 @@ function string_tree( display_variable_names=nothing, X_sym_units=nothing, y_sym_units=nothing, - raw=false, kws..., ) # TODO: HACK we ignore display_variable_names and others diff --git a/src/Strings.jl b/src/Strings.jl index 81fc7f31..c4a3f0dd 100644 --- a/src/Strings.jl +++ b/src/Strings.jl @@ -140,9 +140,14 @@ function string_tree( f_variable::F1=string_variable, f_constant::F2=string_constant, variable_names::Union{AbstractVector{<:AbstractString},Nothing}=nothing, + pretty::Union{Bool,Nothing}=nothing, # Not used, but can be used by other types # Deprecated + raw::Union{Bool,Nothing}=nothing, varMap=nothing, )::String where {T,F1<:Function,F2<:Function} + !isnothing(raw) && + Base.depwarn("`raw` is deprecated; use `pretty` instead", :string_tree) + pretty = @something(pretty, _not(raw), false) variable_names = deprecate_varmap(variable_names, varMap, :string_tree) raw_output = tree_mapreduce( let f_constant = f_constant, @@ -186,14 +191,22 @@ for io in ((), (:(io::IO),)) f_variable::F1=string_variable, f_constant::F2=string_constant, variable_names::Union{AbstractVector{<:AbstractString},Nothing}=nothing, + pretty::Union{Bool,Nothing}=nothing, # Not used, but can be used by other types # Deprecated + raw::Union{Bool,Nothing}=nothing, varMap=nothing, ) where {F1<:Function,F2<:Function} + !isnothing(raw) && + Base.depwarn("`raw` is deprecated; use `pretty` instead", :print_tree) + pretty = @something(pretty, _not(raw), false) variable_names = deprecate_varmap(variable_names, varMap, :print_tree) return println( - $(io...), string_tree(tree, operators; f_variable, f_constant, variable_names) + $(io...), + string_tree(tree, operators; f_variable, f_constant, variable_names, pretty), ) end end +_not(::Nothing) = nothing +_not(x) = !x end