Skip to content

Commit 10e0c15

Browse files
anthonyanthony
authored andcommitted
update a docstring to close #946
1 parent d2892cf commit 10e0c15

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

src/hyperparam/one_dimensional_ranges.jl

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ ERROR_AMBIGUOUS_UNION = ArgumentError(
8888
" in the example, `range(Int, :dummy, lower=1, upper=10)`.")
8989

9090
"""
91-
r = range(model, :hyper; values=nothing)
91+
r = range(model, :hyper; values=...)
9292
9393
Define a one-dimensional `NominalRange` object for a field `hyper` of
9494
`model`. Note that `r` is not directly iterable but `iterator(r)` is.
@@ -97,19 +97,14 @@ A nested hyperparameter is specified using dot notation. For example,
9797
`:(atom.max_depth)` specifies the `max_depth` hyperparameter of
9898
the submodel `model.atom`.
9999
100-
r = range(model, :hyper; upper=nothing, lower=nothing,
101-
scale=nothing, values=nothing)
100+
r = range(model, :hyper; upper=..., lower..., unit=..., origin=...,
101+
scale=nothing)
102102
103-
Assuming `values` is not specified, define a one-dimensional
104-
`NumericRange` object for a `Real` field `hyper` of `model`. Note
105-
that `r` is not directly iteratable but `iterator(r, n)`is an iterator
106-
of length `n`. To generate random elements from `r`, instead apply
107-
`rand` methods to `sampler(r)`. The supported scales are `:linear`,`
108-
:log`, `:logminus`, `:log10`, `:log10minus`, `:log2`, or a callable
109-
object.
110-
111-
Note that `r` is not directly iterable, but `iterator(r, n)` is, for
112-
given resolution (length) `n`.
103+
Define a one-dimensional `NumericRange` object for a `Real` property `hyper` of `model`.
104+
Note that `r` is not directly iteratable but `iterator(r, n)`is an iterator of length
105+
`n`. To generate random elements from `r`, instead apply `rand` methods to
106+
`sampler(r)`. The supported scales are `:linear`,` :log`, `:logminus`, `:log10`,
107+
`:log10minus`, `:log2`, or a callable object.
113108
114109
By default, the behaviour of the constructed object depends on the
115110
type of the value of the hyperparameter `:hyper` at `model` *at the
@@ -119,12 +114,22 @@ behaviour is determined by the value of the specified type.
119114
120115
A nested hyperparameter is specified using dot notation (see above).
121116
117+
# keyword options
118+
122119
If `scale` is unspecified, it is set to `:linear`, `:log`,
123120
`:log10minus`, or `:linear`, according to whether the interval
124121
`(lower, upper)` is bounded, right-unbounded, left-unbounded, or
125122
doubly unbounded, respectively. Note `upper=Inf` and `lower=-Inf` are
126123
allowed.
127124
125+
You must specify at least two of the keyword arguments `upper`, `lower`, `unit` and
126+
`origin`. The last two parameters are used when fitting some distributions to
127+
unbounded `NumericRange` objects. See [`Distributions.fit`](@ref) for details.
128+
129+
A range is *unbounded* if `lower=-Inf` or `upper=Inf`, or one of these is left
130+
unspecified. In this case, both `unit` and `origin` must be specified. In the bounded
131+
case, these have the radius and midpoint of `[lower, upper]` as fallbacks.
132+
128133
If `values` is specified, the other keyword arguments are ignored and
129134
a `NominalRange` object is returned (see above).
130135

0 commit comments

Comments
 (0)