@@ -161,29 +161,36 @@ def unwrap(self) -> T:
161161
162162
163163class RealToIncreasingOnInterval (AbstractUnwrappable [Array ]):
164- """Unconstrained vector to increasing on a fixed interval.
164+ """Map an unconstrained vector to increasing points on a fixed interval.
165165
166- Unconstrained vector is passed into softmax to obtain widths,
167- which are cumulatively summed and scaled to fit the interval
168- (or the remainder not used by min_width) .
166+ The input vector is transformed via a softmax into positive widths, to fill
167+ the interval after adding minimum width. The cumulative sum of the widths
168+ produces the incresing points .
169169
170- Note an array of size d parameterizes widths, so maps to an array
171- of size d+1 if both endpoints are included, d if one is included,
172- and d-1 if neither are included.
170+ If an array of size d is used, the result has size d+1 if both
171+ endpoints are included, d if one is included, and d-1 if neither
172+ are included.
173+
174+ Args:
175+ arr: Unconstrained vector parameterizing the widths.
176+ interval: (lower, upper) bounds of the interval.
177+ min_width: Minimum spacing between consecutive points.
178+ include_endpoints: Which endpoints to include: "both", "neither",
179+ "lower", or "upper".
173180 """
174181
175182 arr : Array
176183 interval : tuple [float | int , float | int ]
177184 min_width : float
178- include_ends : Literal ["both" , "neither" , "lower" , "upper" ]
185+ include_endpoints : Literal ["both" , "neither" , "lower" , "upper" ]
179186
180187 def __init__ (
181188 self ,
182189 arr : Array ,
183190 interval : tuple [float | int , float | int ],
184191 * ,
185192 min_width : float ,
186- include_ends : Literal ["both" , "neither" , "lower" , "upper" ],
193+ include_endpoints : Literal ["both" , "neither" , "lower" , "upper" ],
187194 ):
188195 scale = interval [1 ] - interval [0 ]
189196 n_widths = arr .shape [- 1 ]
@@ -199,10 +206,16 @@ def __init__(
199206 "min_width*n_widths is greater than the interval width, so cannot be "
200207 "satisfied."
201208 )
209+
210+ if include_endpoints not in ["both" , "neither" , "lower" , "upper" ]:
211+ raise ValueError (
212+ "include_endpoints must be one of 'both', 'neither', 'lower', or 'upper'" ,
213+ )
214+
202215 self .arr = arr
203216 self .interval = interval
204217 self .min_width = min_width
205- self .include_ends = include_ends
218+ self .include_endpoints = include_endpoints
206219
207220 def unwrap (self ) -> Array :
208221 scale = self .interval [1 ] - self .interval [0 ]
@@ -216,9 +229,9 @@ def _unwrap(arr):
216229 lower , upper = jnp .array ([self .interval [0 ]]), jnp .array ([self .interval [1 ]])
217230 return jnp .concatenate (
218231 [
219- * ([lower ] if self .include_ends in ("lower" , "both" ) else []),
232+ * ([lower ] if self .include_endpoints in ("lower" , "both" ) else []),
220233 jnp .cumsum (widths , axis = - 1 )[:- 1 ] + lower ,
221- * ([upper ] if self .include_ends in ("upper" , "both" ) else []),
234+ * ([upper ] if self .include_endpoints in ("upper" , "both" ) else []),
222235 ]
223236 )
224237
0 commit comments