Skip to content

Commit 2bfcbed

Browse files
committed
Format and add docs
1 parent e1c7359 commit 2bfcbed

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

docs/src/api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ getp
9292
setp
9393
setp_oop
9494
ParameterIndexingProxy
95+
show_params
9596
```
9697

9798
#### Parameter timeseries

docs/src/complete_sii.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,11 @@ integrator.ps[:b] = 3.0
311311
setp(integrator, :b)(integrator, 3.0) # functionally the same as above
312312
```
313313

314+
The parameters will display as a table:
315+
```@example show_params
316+
integrator.ps
317+
```
318+
314319
## Parameter Timeseries
315320

316321
If a solution object includes modified parameter values (such as through callbacks) during the

src/parameter_indexing_proxy.jl

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,16 @@ function Base.show(io::IO, ::MIME"text/plain", pip::ParameterIndexingProxy)
2323
end
2424

2525
"""
26-
showparams(io::IO, pip::ParameterIndexingProxy; num_rows = 20, show_all = false, scalarize = true, kwargs...)
26+
show_params(io::IO, pip::ParameterIndexingProxy; num_rows = 20, show_all = false, scalarize = true, kwargs...)
2727
2828
Method for customizing the table output. Keyword args:
2929
- num_rows
3030
- show_all: whether to show all parameters. Overrides `num_rows`.
3131
- scalarize: whether to scalarize array symbolics in the table output.
3232
- kwargs... are passed to the pretty_table call.
3333
"""
34-
function showparams(io::IO, pip::ParameterIndexingProxy; num_rows = 20, show_all = false, scalarize = true, kwargs...)
34+
function showparams(io::IO, pip::ParameterIndexingProxy; num_rows = 20,
35+
show_all = false, scalarize = true, kwargs...)
3536
params = Any[]
3637
vals = Any[]
3738
for p in parameter_symbols(pip.wrapped)
@@ -49,21 +50,21 @@ function showparams(io::IO, pip::ParameterIndexingProxy; num_rows = 20, show_all
4950
end
5051

5152
num_shown = if show_all
53+
length(params)
54+
else
55+
if num_rows > length(params)
5256
length(params)
5357
else
54-
if num_rows > length(params)
55-
length(params)
56-
else
57-
num_rows
58-
end
58+
num_rows
5959
end
60+
end
6061

6162
pretty_table(io, [params[1:num_shown] vals[1:num_shown]];
62-
header=["Parameter", "Value"],
63-
kwargs...)
63+
header = ["Parameter", "Value"],
64+
kwargs...)
6465

6566
if num_shown < length(params)
66-
println(io,
67-
"$num_shown of $(length(params)) params shown. To show all the parameters, call `showparams(io, ps, show_all = true)`. Adjust the number of rows with the num_rows kwarg. Consult `showparams` docstring for more options.")
67+
println(io,
68+
"$num_shown of $(length(params)) params shown. To show all the parameters, call `show_params(io, ps, show_all = true)`. Adjust the number of rows with the num_rows kwarg. Consult `show_params` docstring for more options.")
6869
end
6970
end

0 commit comments

Comments
 (0)