File: PKG-INFO

package info (click to toggle)
csaps 1.3.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 148 kB
  • sloc: python: 611; makefile: 6
file content (177 lines) | stat: -rw-r--r-- 5,894 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
Metadata-Version: 2.3
Name: csaps
Version: 1.3.3
Summary: Cubic spline approximation (smoothing)
License: MIT
Keywords: cubic,spline,approximation,smoothing,interpolation,csaps
Author: Evgeny Prilepin
Author-email: esp.home@gmail.com
Requires-Python: >=3.10
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Software Development :: Libraries
Requires-Dist: numpy (>=1.26.2) ; python_version >= "3.12"
Requires-Dist: numpy ; python_version < "3.12"
Requires-Dist: scipy (>=1.11.4) ; python_version >= "3.12"
Requires-Dist: scipy ; python_version < "3.12"
Requires-Dist: typing-extensions
Project-URL: Documentation, https://csaps.readthedocs.io
Project-URL: Homepage, https://github.com/espdev/csaps
Project-URL: Repository, https://github.com/espdev/csaps
Description-Content-Type: text/markdown

<p align="center">
  <a href="https://github.com/espdev/csaps"><img src="https://user-images.githubusercontent.com/1299189/76571441-8d97e400-64c8-11ea-8c05-58850f8311a1.png" alt="csaps" width="400" /></a><br>
</p>

<p align="center">
  <a href="https://pypi.python.org/pypi/csaps"><img src="https://img.shields.io/pypi/v/csaps.svg" alt="PyPI version" /></a>
  <a href="https://pypi.python.org/pypi/csaps"><img src="https://img.shields.io/pypi/pyversions/csaps.svg" alt="Supported Python versions" /></a>
  <a href="https://github.com/espdev/csaps"><img src="https://github.com/espdev/csaps/workflows/main/badge.svg" alt="GitHub Actions (Tests)" /></a>
  <a href="https://csaps.readthedocs.io/en/latest/?badge=latest"><img src="https://readthedocs.org/projects/csaps/badge/?version=latest" alt="Documentation Status" /></a>
  <a href="https://coveralls.io/github/espdev/csaps?branch=master"><img src="https://coveralls.io/repos/github/espdev/csaps/badge.svg?branch=master" alt="Coverage Status" /></a>
  <a href="https://choosealicense.com/licenses/mit/"><img src="https://img.shields.io/pypi/l/csaps.svg" alt="License" /></a>
</p>

**csaps** is a Python package for univariate, multivariate and n-dimensional grid data approximation using cubic smoothing splines.
The package can be useful in practical engineering tasks for data approximation and smoothing.

## Installing

Use pip for installing:

```
pip install -U csaps
```

or Poetry:

```
poetry add csaps
```

The module depends only on NumPy and SciPy. Python 3.10 or above is supported.

## Simple Examples

Here is a couple of examples of smoothing data.

An univariate data smoothing:

```python
import numpy as np
import matplotlib.pyplot as plt

from csaps import csaps

np.random.seed(1234)

x = np.linspace(-5., 5., 25)
y = np.exp(-(x/2.5)**2) + (np.random.rand(25) - 0.2) * 0.3
xs = np.linspace(x[0], x[-1], 150)

ys = csaps(x, y, xs, smooth=0.85)

plt.plot(x, y, 'o', xs, ys, '-')
plt.show()
```

<p align="center">
  <img src="https://user-images.githubusercontent.com/1299189/72231304-cd774380-35cb-11ea-821d-d5662cc1eedf.png" alt="univariate" />
<p/>

A surface data smoothing:

```python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

from csaps import csaps

np.random.seed(1234)
xdata = [np.linspace(-3, 3, 41), np.linspace(-3.5, 3.5, 31)]
i, j = np.meshgrid(*xdata, indexing='ij')
ydata = (3 * (1 - j)**2. * np.exp(-(j**2) - (i + 1)**2)
         - 10 * (j / 5 - j**3 - i**5) * np.exp(-j**2 - i**2)
         - 1 / 3 * np.exp(-(j + 1)**2 - i**2))
ydata = ydata + (np.random.randn(*ydata.shape) * 0.75)

ydata_s = csaps(xdata, ydata, xdata, smooth=0.988)

fig = plt.figure(figsize=(7, 4.5))
ax = fig.add_subplot(111, projection='3d')
ax.set_facecolor('none')
c = [s['color'] for s in plt.rcParams['axes.prop_cycle']]
ax.plot_wireframe(j, i, ydata, linewidths=0.5, color=c[0], alpha=0.5)
ax.scatter(j, i, ydata, s=10, c=c[0], alpha=0.5)
ax.plot_surface(j, i, ydata_s, color=c[1], linewidth=0, alpha=1.0)
ax.view_init(elev=9., azim=290)

plt.show()
```

<p align="center">
  <img src="https://user-images.githubusercontent.com/1299189/72231252-7a9d8c00-35cb-11ea-8890-487b8a7dbd1d.png" alt="surface" />
<p/>

## Documentation

More examples of usage and the full documentation can be found at https://csaps.readthedocs.io.

## Development

We use Poetry to manage the project:

```
git clone https://github.com/espdev/csaps.git
cd csaps
poetry install -E docs
```

Also, install pre-commit hooks:

```
poetry run pre-commit install
```

## Testing and Linting

We use pytest for testing and ruff/mypy for linting.
Use `poethepoet` to run tests and linters:

```
poetry run poe test
poetry run poe check
```

## Algorithm and Implementation

**csaps** Python package is inspired by MATLAB [CSAPS](https://www.mathworks.com/help/curvefit/csaps.html) function that is an implementation of 
Fortran routine SMOOTH from [PGS](http://pages.cs.wisc.edu/~deboor/pgs/) (originally written by Carl de Boor).

Also, the algothithm implementation in other languages:

* [csaps-rs](https://github.com/espdev/csaps-rs) Rust ndarray/sprs based implementation
* [csaps-cpp](https://github.com/espdev/csaps-cpp) C++11 Eigen based implementation (incomplete)

## References

C. de Boor, A Practical Guide to Splines, Springer-Verlag, 1978.

## License

[MIT](https://choosealicense.com/licenses/mit/)