Skip to content

Commit

Permalink
add stubs for glam_fit
Browse files Browse the repository at this point in the history
  • Loading branch information
jvansanten committed Sep 19, 2023
1 parent 9ab95b8 commit 54330dd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
36 changes: 29 additions & 7 deletions src/python/photospline.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,50 @@ import numpy.typing as npt

class SplineTable:
coefficients: npt.NDArray[np.float32]
extents: tuple[tuple[float,float], ...]
extents: tuple[tuple[float, float], ...]
knots: tuple[npt.NDArray[np.float32], ...]
ndim: int
order: tuple[int, ...]

def __init__(self, path: str): ...

@classmethod
def stack(cls, tables: Sequence[SplineTable], coordinates: Sequence[float], stackOrder: int = 2) -> SplineTable:
"""
"""
def stack(
cls,
tables: Sequence[SplineTable],
coordinates: Sequence[float],
stackOrder: int = 2,
) -> SplineTable:
""" """
...

def aux_value(self, *args, **kwargs) -> Any: ...
def convolve(self, *args, **kwargs) -> Any: ...
def deriv(self, *args, **kwargs) -> Any: ...
def evaluate(self, *args, **kwargs) -> Any: ...
def evaluate_gradient(self, *args, **kwargs) -> Any: ...
def evaluate_simple(self, *args, **kwargs) -> Any: ...
def grideval(self, *args, **kwargs) -> Any: ...
def permute_dimensions(self, *args, **kwargs) -> Any: ...
def search_centers(self, *args, **kwargs) -> Any: ...
def write(self, *args, **kwargs) -> Any: ...
def __call__(self, *args, **kwargs) -> Any: ...

def bspline(*args, **kwargs) -> Any: ...
class ndsparse:
def __init__(self, rows: int, ndim: int) -> None: ...
@classmethod
def from_data(
cls, values: npt.ArrayLike, weights: None | npt.ArrayLike = None
) -> tuple[ndsparse, ndsparse]: ...
def insert(self, value: float, indices: Sequence[int]) -> None: ...

def bspline(knots: npt.ArrayLike, x: float, index: int, order: int) -> float: ...
def glam_fit(
data: ndsparse,
weights: ndsparse,
coordinates: Sequence[Sequence[float]],
knots: Sequence[Sequence[float]],
order: Sequence[int],
smoothing: Sequence[float],
penaltyOrder: Sequence[int],
monodim: None | int = None,
verbose: int = 1,
) -> SplineTable: ...
4 changes: 2 additions & 2 deletions test/test_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def pad_knots(knots, order=2):
order = [2,2,3]
smooth = 1

data, w = photospline.ndsparse.from_data(z, w)
spline = photospline.glam_fit(data, w, centers, knots, order, [smooth]*3, [2]*3, monodim=2, verbose=False)
data, ws = photospline.ndsparse.from_data(z, w)
spline = photospline.glam_fit(data, ws, centers, knots, order, [smooth]*3, [2]*3, monodim=2, verbose=False)
y = spline.grideval(centers)

residual = ((z-y)**2).sum()
Expand Down

0 comments on commit 54330dd

Please sign in to comment.