Skip to content

Commit

Permalink
format the docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengp0 committed Mar 27, 2024
1 parent 5a703d1 commit b77f980
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/regmod/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def scipy_optimize(
-------
NDArray
Optimal solution.
"""
x0 = np.zeros(model.size) if x0 is None else x0
bounds = model.uvec.T
Expand Down Expand Up @@ -88,6 +89,7 @@ def set_trim_weights(model: "Model", index: NDArray, mask: float):
Index where the weights need to be set.
mask : float
Value of the weights to set.
"""
weights = np.ones(model.data.num_obs)
weights[index] = mask
Expand All @@ -106,6 +108,7 @@ def trimming(optimize: Callable) -> Callable:
-------
Callable
Trimming optimization solver.
"""

def optimize_with_trimming(
Expand Down
5 changes: 5 additions & 0 deletions src/regmod/prior.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class GaussianPrior(Prior):
Raised when size of the standard deviation vector doesn't match.
ValueError
Raised when any value in standard deviation vector is non-positive.
"""

mean: NDArray = field(default=0.0, repr=False)
Expand Down Expand Up @@ -151,6 +152,7 @@ class UniformPrior(Prior):
Raised when size of the upper bound vector doesn't match.
ValueError
Raised if lower bound is greater than upper bound.
"""

lb: NDArray = field(default=-np.inf, repr=False)
Expand Down Expand Up @@ -195,6 +197,7 @@ class LinearPrior:
-------
is_empty()
Indicate if the prior is empty.
"""

mat: NDArray = field(default_factory=lambda: np.empty(shape=(0, 1)), repr=False)
Expand Down Expand Up @@ -258,6 +261,7 @@ class SplinePrior(LinearPrior):
-------
attach_spline(spline)
Attach the spline to process the domain.
"""

size: int = 100
Expand All @@ -283,6 +287,7 @@ def attach_spline(self, spline: XSpline):
----------
spline : XSpline
Spline used to create the linear mapping for the prior.
"""
knots_lb = spline.knots[0]
knots_ub = spline.knots[-1]
Expand Down
5 changes: 5 additions & 0 deletions src/regmod/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def default_vec_factory(
Notes
-----
This function should be replaced in the next version.
"""

if vec is None or np.isscalar(vec):
Expand Down Expand Up @@ -66,6 +67,7 @@ def check_size(vec: NDArray, size: int, vec_name: str = "vec") -> None:
Notes
-----
This function should be replaced in the next version.
"""
assert len(vec) == size, f"{vec_name} must length {size}."

Expand Down Expand Up @@ -104,6 +106,7 @@ class SplineSpecs:
-------
create_spline(vec)
Create the spline from given vector as the data.
"""

knots: NDArray
Expand Down Expand Up @@ -146,6 +149,7 @@ def create_spline(self, vec: NDArray | None = None) -> XSpline:
-------
XSpline
Spline object.
"""
if self.knots_type == "abs":
knots = self.knots
Expand Down Expand Up @@ -198,6 +202,7 @@ def sizes_to_slices(sizes: list[int]) -> list[slice]:
[0, 1, 2, 3, 4, 5]
>>> [x[s] for s in slices]
[[0], [1, 2], [3, 4, 5]]
"""
sizes = np.asarray(sizes).astype(int)
if any(sizes < 0):
Expand Down

0 comments on commit b77f980

Please sign in to comment.