FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix sp solve warning by espdev · Pull Request #102 · espdev/csaps · GitHub

/ csaps Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .lock  (1) .py  (1) .yaml  (1) All 3 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
matrix:
platform: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
python-version: [ "3.10", "3.11", "3.12", "3.13" ]
poetry-version: [ "2.0.1" ]
poetry-version: [ "2.1.4" ]

steps:
- name: Checkout project
Expand Down
13 changes: 7 additions & 6 deletions csaps/_sspumv.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from typing import Literal, cast
import functools
from functools import partial

import numpy as np
from scipy.interpolate import PPoly
Expand All @@ -14,6 +14,9 @@
from ._reshape import prod, to_2d
from ._types import FloatNDArrayType, MultivariateDataType, UnivariateDataType

diags_csr = partial(sp.diags, format='csr')
vpad = partial(np.pad, pad_width=[(1, 1), (0, 0)], mode='constant')


class SplinePPForm(ISplinePPForm[np.ndarray, int], PPoly):
"""The base class for univariate/multivariate spline in piecewise polynomial form
Expand Down Expand Up @@ -282,13 +285,13 @@ def _make_spline(x, y, w, smooth, shape, normalizedsmooth):

# Create diagonal sparse matrices
diags_r = np.vstack((dx[1:], 2 * (dx[1:] + dx[:-1]), dx[:-1]))
r = sp.spdiags(diags_r, [-1, 0, 1], pcount - 2, pcount - 2)
r = sp.spdiags(diags_r, [-1, 0, 1], pcount - 2, pcount - 2, format='csr')

dx_recip = 1.0 / dx
diags_qtw = np.vstack((dx_recip[:-1], -(dx_recip[1:] + dx_recip[:-1]), dx_recip[1:]))
diags_sqrw_recip = 1.0 / np.sqrt(w)

qtw = sp.diags(diags_qtw, [0, 1, 2], (pcount - 2, pcount)) @ sp.diags(diags_sqrw_recip, 0, (pcount, pcount))
qtw = diags_csr(diags_qtw, [0, 1, 2], (pcount - 2, pcount)) @ diags_csr(diags_sqrw_recip, 0, (pcount, pcount))
qtw = qtw @ qtw.T

p = smooth
Expand All @@ -312,13 +315,11 @@ def _make_spline(x, y, w, smooth, shape, normalizedsmooth):

dx = dx[:, np.newaxis]

vpad = functools.partial(np.pad, pad_width=[(1, 1), (0, 0)], mode='constant')

d1 = np.diff(vpad(u), axis=0) / dx
d2 = np.diff(vpad(d1), axis=0)

diags_w_recip = 1.0 / w
w = sp.diags(diags_w_recip, 0, (pcount, pcount))
w = diags_csr(diags_w_recip, 0, (pcount, pcount))

yi = y.T - (pp * w) @ d2
pu = vpad(p * u)
Expand Down
Loading
Loading

Back | FazBrowse Home | New Git URL