Skip to content

Commit

Permalink
add `` for typing
Browse files Browse the repository at this point in the history
  • Loading branch information
PFLeget committed Sep 16, 2024
1 parent 2e6f54b commit db740bc
Showing 1 changed file with 55 additions and 55 deletions.
110 changes: 55 additions & 55 deletions python/lsst/meas/algorithms/gp_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ def jax_pdist_squared(x):
Parameters:
----------
x : array-like
x : `np.array`
Input array of shape (n_samples, n_features).
Returns:
-------
dist : ndarray
dist : `np.array`
Array of shape (n_samples, n_samples) containing the squared pairwise Euclidean distances.
Notes:
Expand All @@ -123,14 +123,14 @@ def jax_cdist_squared(xa, xb):
Parameters
----------
xa : array-like, shape (n_samples_a, n_features)
xa : `np.array`, shape (n_samples_a, n_features)
The first set of points.
xb : array-like, shape (n_samples_b, n_features)
xb : `np.array`, shape (n_samples_b, n_features)
The second set of points.
Returns
-------
dist : ndarray, shape (n_samples_a, n_samples_b)
dist : `np.array`, shape (n_samples_a, n_samples_b)
The squared Euclidean distance between each pair of points.
Notes
Expand Down Expand Up @@ -158,18 +158,18 @@ def jax_rbf_kernel(x, sigma, correlation_length, y_err):
Parameters:
-----------
x : array-like
x : `np.array`
Input data points with shape (n_samples, n_features).
sigma : float
sigma : `float`
The scale parameter of the kernel.
correlation_length : float
correlation_length : `float`
The correlation length parameter of the kernel.
y_err : float
y_err : `float`
Measurement error for the input values.
Returns:
--------
kernel : array-like
kernel : `np.array`
RBF kernel matrix with shape (n_samples, n_samples).
"""
distance_squared = jax_pdist_squared(x)
Expand All @@ -185,18 +185,18 @@ def jax_rbf_kernel_rect(x1, x2, sigma, correlation_length):
Compute the radial basis function (RBF) kernel (rectangular matrix).
Parameters:
-----------
x1 : array-like
x1 : `np.array`
The first set of input points.
x2 : array-like
x2 : `np.array`
The second set of input points.
sigma : float
sigma : `float`
The scale parameter of the kernel.
correlation_length : float
The correlation length parameter of the kernel.
Returns:
--------
kernel_rect : ndarray
kernel_rect : `np.array`
The computed RBF kernel (rectangular matrix).
"""
Expand All @@ -212,14 +212,14 @@ def jax_get_alpha(y, kernel):
Parameters:
-----------
y : array_like
y : `np.array`
The target values of the Gaussian Process.
kernel : array_like
kernel : `np.array`
The kernel matrix of the Gaussian Process.
Returns:
--------
alpha : ndarray
alpha : `np.array`
The alpha vector computed using the Cholesky decomposition and solve.
"""
Expand All @@ -235,14 +235,14 @@ def jax_get_y_predict(kernel_rect, alpha):
Parameters:
-----------
kernel_rect : array-like
kernel_rect : `np.array`
The kernel matrix.
alpha : array-like
alpha : `np.array`
The alpha vector.
Returns:
--------
array-like
`np.array`
The predicted values of y.
"""
Expand Down Expand Up @@ -277,13 +277,13 @@ class GaussianProcessTreegp:
Parameters:
-----------
std : float, optional
std : `float`, optional
Standard deviation of the Gaussian Process kernel. Default is 1.0.
correlation_length : float, optional
correlation_length : `float`, optional
Correlation length of the Gaussian Process kernel. Default is 1.0.
white_noise : float, optional
white_noise : `float`, optional
White noise level of the Gaussian Process. Default is 0.0.
mean : float, optional
mean : `float`, optional
Mean value of the Gaussian Process. Default is 0.0.
Methods:
Expand All @@ -293,22 +293,22 @@ class GaussianProcessTreegp:
Parameters:
-----------
x_good : array-like
x_good : `np.array`
Input features for the training data.
y_good : array-like
y_good : `np.array`
Target values for the training data.
predict(x_bad):
Predict the target values for the given input features.
Parameters:
-----------
x_bad : array-like
x_bad : `np.array`
Input features for the prediction.
Returns:
--------
y_pred : array-like
y_pred : `np.array`
Predicted target values.
"""
Expand All @@ -325,9 +325,9 @@ def fit(self, x_good, y_good):
Parameters:
-----------
x_good : array-like
x_good : `np.array`
Input features for the training data.
y_good : array-like
y_good : `np.array`
Target values for the training data.
"""
kernel = f"{self.std}**2 * RBF({self.correlation_length})"
Expand All @@ -346,12 +346,12 @@ def predict(self, x_bad):
Parameters:
-----------
x_bad : array-like
x_bad : `np.array`
Input features for the prediction.
Returns:
--------
y_pred : array-like
y_pred : `np.array`
Predicted target values.
"""
y_pred = self.gp.predict(x_bad)
Expand All @@ -367,19 +367,19 @@ class InterpolateOverDefectGaussianProcess:
-----------
maskedImage : `lsst.afw.image.MaskedImage`
The masked image containing the defects to be interpolated.
defects : list of str, optional
defects : `list`[`str`], optional
The types of defects to be interpolated. Default is ["SAT"].
method : str, optional
method : `str`, optional
The method to use for GP interpolation. Must be either "jax" or "treegp". Default is "treegp".
fwhm : float, optional
fwhm : `float`, optional
The full width at half maximum (FWHM) of the PSF. Default is 5.
bin_spacing : int, optional
bin_spacing : `int`, optional
The spacing between bins for good pixel binning. Default is 10.
threshold_dynamic_binning : int, optional
threshold_dynamic_binning : `int`, optional
The threshold for dynamic binning. Default is 1000.
threshold_subdivide : int, optional
threshold_subdivide : `int`, optional
The threshold for sub-dividing the bad pixel array to avoid memory error. Default is 20000.
correlation_length_cut : int, optional
correlation_length_cut : `int`, optional
The factor by which to dilate the bounding box around defects. Default is 5.
Raises:
Expand All @@ -389,21 +389,21 @@ class InterpolateOverDefectGaussianProcess:
Attributes:
-----------
bin_spacing : int
bin_spacing : `int`
The spacing between bins for good pixel binning.
threshold_subdivide : int
threshold_subdivide : `int`
The threshold for sub-dividing the bad pixel array to avoid memory error.
threshold_dynamic_binning : int
threshold_dynamic_binning : `int`
The threshold for dynamic binning.
maskedImage : `lsst.afw.image.MaskedImage`
The masked image containing the defects to be interpolated.
defects : list of str
defects : `list`[`str`]
The types of defects to be interpolated.
correlation_length : float
correlation_length : `float`
The correlation length (FWHM).
correlation_length_cut : int
correlation_length_cut : `int`
The factor by which to dilate the bounding box around defects.
interpBit : int
interpBit : `int`
The bit mask for the "INTRP" plane in the image mask.
Methods:
Expand Down Expand Up @@ -485,12 +485,12 @@ def _good_pixel_binning(self, good_pixel):
Parameters:
-----------
good_pixel : numpy.ndarray
good_pixel : `np.array`
The array of good pixels.
Returns:
--------
numpy.ndarray
`np.array`
The binned array of good pixels.
"""

Expand Down Expand Up @@ -605,19 +605,19 @@ def interpolateOverDefectsGP(
Parameters
----------
image : ndarray
image : `np.array`
The input image.
fwhm : float
fwhm : `float`
The full width at half maximum (FWHM) of the Gaussian kernel used for interpolation.
badList : list
badList : `list`
A list of defect coordinates in the image.
method : str, optional
method : `str`, optional
The method used for interpolation. Default is "treegp".
bin_spacing : int, optional
bin_spacing : `int`, optional
The spacing between bins used for dynamic binning. Default is 25.
threshold_dynamic_binning : int, optional
threshold_dynamic_binning : `int`, optional
The threshold for dynamic binning. Default is 1000.
threshold_subdivide : int, optional
threshold_subdivide : `int`, optional
The threshold for subdividing defects. Default is 20000.
Returns
Expand Down

0 comments on commit db740bc

Please sign in to comment.