Skip to content

Commit

Permalink
Minor and add parenthesize_modforms
Browse files Browse the repository at this point in the history
  • Loading branch information
giopaglia committed Dec 7, 2023
1 parent f8ddc59 commit 3645303
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/logisets/multilogiset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ function syntaxstring(
f::MultiFormula;
hidemodality = false,
variable_names_map::Union{Nothing,AbstractDict,AbstractVector,AbstractVector{<:Union{AbstractDict,AbstractVector}}} = nothing,
parenthesize_modforms = true,
kwargs...
)
map_is_multimodal = begin
Expand All @@ -240,8 +241,13 @@ function syntaxstring(
end
join([begin
_variable_names_map = map_is_multimodal ? variable_names_map[i_modality] : variable_names_map
φ = syntaxstring(modforms(f)[i_modality]; variable_names_map = _variable_names_map, kwargs...)
hidemodality ? "" : "{$(i_modality)}()"
φ = modforms(f)[i_modality]
str = syntaxstring(φ; variable_names_map = _variable_names_map, kwargs...)
parenthesize = !isa SyntaxBranch) ||isa SyntaxBranch && SoleLogics.isunary(token(φ)))
if parenthesize && parenthesize_modforms
str = "($str)"
end
hidemodality ? "$str" : "{$(i_modality)}$str"
end for i_modality in sort(collect(keys(modforms(f))))], " $(CONJUNCTION) ")
end

Expand Down
2 changes: 1 addition & 1 deletion src/logisets/supported-logiset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function displaystructure(
)
padattribute(l,r) = string(l) * lpad(r,32+length(string(r))-(length(indent_str)+2+length(l))-1)
pieces = []
push!(pieces, "SupportedLogiset with $(nsupports(X)) supports ($(humansize(X)))")
push!(pieces, "SupportedLogiset with $(nsupports(X)) $(nsupports(X) == 1 ? "support" : "supports") ($(humansize(X)))")
if ismissing(include_worldtype) || include_worldtype != worldtype(X)
push!(pieces, " " * padattribute("worldtype:", worldtype(X)))
end
Expand Down
1 change: 1 addition & 0 deletions src/models/symbolic-utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ _submodels(m::DecisionForest) = [Iterators.flatten(_submodels.(immediatesubmodel
_submodels(m::MixedSymbolicModel) = [Iterators.flatten(_submodels.(immediatesubmodels(m)))...]

nsubmodels(m::AbstractModel) = 1 + sum(nsubmodels, immediatesubmodels(m))
nsubmodels(m::LeafModel) = 1
nsubmodels(m::DecisionList) = sum(nsubmodels, immediatesubmodels(m))
nsubmodels(m::DecisionTree) = sum(nsubmodels, immediatesubmodels(m))
nsubmodels(m::DecisionForest) = sum(nsubmodels, immediatesubmodels(m))
Expand Down

0 comments on commit 3645303

Please sign in to comment.