Skip to content

Commit eb32401

Browse files
authored
Max issues default (#20)
* Change max issues default * format * add missing test
1 parent 8b15bac commit eb32401

File tree

5 files changed

+36
-5
lines changed

5 files changed

+36
-5
lines changed

src/ModelAnalyzer.jl

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ See [`summarize`](@ref), [`list_of_issues`](@ref), and
2525
function analyze end
2626

2727
"""
28-
summarize([io::IO,] AbstractData; verbose = true, max_issues = typemax(Int), kwargs...)
28+
summarize([io::IO,] AbstractData; verbose = true, max_issues = 10, kwargs...)
2929
3030
Print a summary of the analysis results contained in `AbstractData` to the
3131
specified IO stream. If no IO stream is provided, it defaults to `stdout`.
@@ -80,16 +80,26 @@ function summarize(io::IO, issue::AbstractIssue; verbose = true)
8080
end
8181
end
8282

83+
const DEFAULT_MAX_ISSUES = 10
84+
8385
function summarize(
8486
io::IO,
8587
issues::Vector{T};
8688
verbose = true,
87-
max_issues = typemax(Int),
89+
max_issues = DEFAULT_MAX_ISSUES,
8890
) where {T<:AbstractIssue}
8991
summarize(io, T, verbose = verbose)
9092
print(io, "\n## Number of issues\n\n")
9193
print(io, "Found ", length(issues), " issues")
9294
print(io, "\n\n## List of issues\n\n")
95+
if length(issues) > max_issues
96+
print(
97+
io,
98+
"Showing first ",
99+
max_issues,
100+
" issues ($(length(issues) - max_issues) issues ommitted)\n\n",
101+
)
102+
end
93103
for issue in first(issues, max_issues)
94104
print(io, " * ")
95105
summarize(io, issue, verbose = verbose)

src/feasibility.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ function ModelAnalyzer.summarize(
685685
io::IO,
686686
data::Data;
687687
verbose = true,
688-
max_issues = typemax(Int),
688+
max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES,
689689
configurations = true,
690690
)
691691
print(io, "## Feasibility Analysis\n\n")

src/infeasibility.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ function ModelAnalyzer.summarize(
677677
io::IO,
678678
data::Data;
679679
verbose = true,
680-
max_issues = typemax(Int),
680+
max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES,
681681
)
682682
print(io, "## Infeasibility Analysis\n\n")
683683

src/numerical.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,7 @@ function ModelAnalyzer.summarize(
20422042
io::IO,
20432043
data::Data;
20442044
verbose = true,
2045-
max_issues = typemax(Int),
2045+
max_issues = ModelAnalyzer.DEFAULT_MAX_ISSUES,
20462046
configurations = true,
20472047
dimensions = true,
20482048
ranges = true,

test/numerical.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,6 +1002,27 @@ function test_qp_range()
10021002
return
10031003
end
10041004

1005+
function test_more_than_max_issues()
1006+
model = Model()
1007+
@variable(model, xg[1:20] <= 2e9)
1008+
data = ModelAnalyzer.analyze(ModelAnalyzer.Numerical.Analyzer(), model)
1009+
list = ModelAnalyzer.list_of_issue_types(data)
1010+
@test length(list) >= 1
1011+
ret = ModelAnalyzer.list_of_issues(
1012+
data,
1013+
ModelAnalyzer.Numerical.LargeBoundCoefficient,
1014+
)
1015+
@test length(ret) == 20
1016+
1017+
buf = IOBuffer()
1018+
ModelAnalyzer.summarize(buf, data)
1019+
str = String(take!(buf))
1020+
@test occursin("Showing first ", str)
1021+
@test occursin(" issues ommitted)\n\n", str)
1022+
1023+
return
1024+
end
1025+
10051026
end # module
10061027

10071028
TestNumerical.runtests()

0 commit comments

Comments
 (0)