diff options
Diffstat (limited to 'python-numpy-ext.spec')
| -rw-r--r-- | python-numpy-ext.spec | 252 |
1 files changed, 252 insertions, 0 deletions
diff --git a/python-numpy-ext.spec b/python-numpy-ext.spec new file mode 100644 index 0000000..83b9474 --- /dev/null +++ b/python-numpy-ext.spec @@ -0,0 +1,252 @@ +%global _empty_manifest_terminate_build 0 +Name: python-numpy-ext +Version: 0.9.8 +Release: 1 +Summary: numpy extension +License: MIT License +URL: https://github.com/3jane/numpy_ext +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/69/8c/7fee8ed19be051a37a4646e8dac78eecf07da0118ddf610eb890b99d0744/numpy_ext-0.9.8.tar.gz +BuildArch: noarch + +Requires: python3-numpy +Requires: python3-joblib +Requires: python3-flake8 +Requires: python3-pytest +Requires: python3-pytest-cov +Requires: python3-pandas +Requires: python3-numpydoc +Requires: python3-sphinx +Requires: python3-Jinja2 + +%description +## Documentation +* [API Reference](http://3jane.github.io/numpy_ext/) +## Installation +Regular installation: +```bash +pip install numpy_ext +``` +For development: +```bash +git clone https://github.com/3jane/numpy_ext.git +cd numpy_ext +pip install -e .[dev] # note: make sure you are using pip>=20 +``` +## Examples +Here are few common examples of how the library is used. The rest is available in the [documentation](http://3jane.github.io/numpy_ext/). +1) Apply a function to a rolling window over the provided array +```python +import numpy as np +import numpy_ext as npext +a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +window = 3 +npext.rolling_apply(np.sum, window, a) +> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.]) +``` +2) Same as the above, but with a custom function, two input arrays and parallel computation using `joblib`: +```python +def func(array_first, array_second, param): + return (np.min(array_first) + np.sum(array_second)) * param +a = np.array([0, 1, 2, 3]) +b = np.array([3, 2, 1, 0]) +npext.rolling_apply(func, 2, a, b, n_jobs=2, param=-1) +> array([nan, -5., -4., -3.]) +``` +3) Same as the first example, but using **rolling** function: +```python +a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +window = 3 +rolls = npext.rolling(a, window, as_array=True) +np.sum(rolls, axis=1) +> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.]) +``` +4) Apply a function with multiple output to a rolling window over the provided array, with no nans prepend +```python +res = npext.rolling_apply( + lambda x: (max(x), min(x)), + 3, + np.array([1, 2, 5, 1, 6, 4, 0]), + prepend_nans=False, + ) +> array([[5, 1], + [5, 1], + [6, 1], + [6, 1], + [6, 0]]) +``` +## License +[](https://tldrlegal.com/license/mit-license) +The software is distributed under MIT license. + +%package -n python3-numpy-ext +Summary: numpy extension +Provides: python-numpy-ext +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-numpy-ext +## Documentation +* [API Reference](http://3jane.github.io/numpy_ext/) +## Installation +Regular installation: +```bash +pip install numpy_ext +``` +For development: +```bash +git clone https://github.com/3jane/numpy_ext.git +cd numpy_ext +pip install -e .[dev] # note: make sure you are using pip>=20 +``` +## Examples +Here are few common examples of how the library is used. The rest is available in the [documentation](http://3jane.github.io/numpy_ext/). +1) Apply a function to a rolling window over the provided array +```python +import numpy as np +import numpy_ext as npext +a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +window = 3 +npext.rolling_apply(np.sum, window, a) +> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.]) +``` +2) Same as the above, but with a custom function, two input arrays and parallel computation using `joblib`: +```python +def func(array_first, array_second, param): + return (np.min(array_first) + np.sum(array_second)) * param +a = np.array([0, 1, 2, 3]) +b = np.array([3, 2, 1, 0]) +npext.rolling_apply(func, 2, a, b, n_jobs=2, param=-1) +> array([nan, -5., -4., -3.]) +``` +3) Same as the first example, but using **rolling** function: +```python +a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +window = 3 +rolls = npext.rolling(a, window, as_array=True) +np.sum(rolls, axis=1) +> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.]) +``` +4) Apply a function with multiple output to a rolling window over the provided array, with no nans prepend +```python +res = npext.rolling_apply( + lambda x: (max(x), min(x)), + 3, + np.array([1, 2, 5, 1, 6, 4, 0]), + prepend_nans=False, + ) +> array([[5, 1], + [5, 1], + [6, 1], + [6, 1], + [6, 0]]) +``` +## License +[](https://tldrlegal.com/license/mit-license) +The software is distributed under MIT license. + +%package help +Summary: Development documents and examples for numpy-ext +Provides: python3-numpy-ext-doc +%description help +## Documentation +* [API Reference](http://3jane.github.io/numpy_ext/) +## Installation +Regular installation: +```bash +pip install numpy_ext +``` +For development: +```bash +git clone https://github.com/3jane/numpy_ext.git +cd numpy_ext +pip install -e .[dev] # note: make sure you are using pip>=20 +``` +## Examples +Here are few common examples of how the library is used. The rest is available in the [documentation](http://3jane.github.io/numpy_ext/). +1) Apply a function to a rolling window over the provided array +```python +import numpy as np +import numpy_ext as npext +a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +window = 3 +npext.rolling_apply(np.sum, window, a) +> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.]) +``` +2) Same as the above, but with a custom function, two input arrays and parallel computation using `joblib`: +```python +def func(array_first, array_second, param): + return (np.min(array_first) + np.sum(array_second)) * param +a = np.array([0, 1, 2, 3]) +b = np.array([3, 2, 1, 0]) +npext.rolling_apply(func, 2, a, b, n_jobs=2, param=-1) +> array([nan, -5., -4., -3.]) +``` +3) Same as the first example, but using **rolling** function: +```python +a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) +window = 3 +rolls = npext.rolling(a, window, as_array=True) +np.sum(rolls, axis=1) +> array([nan, nan, 3., 6., 9., 12., 15., 18., 21., 24.]) +``` +4) Apply a function with multiple output to a rolling window over the provided array, with no nans prepend +```python +res = npext.rolling_apply( + lambda x: (max(x), min(x)), + 3, + np.array([1, 2, 5, 1, 6, 4, 0]), + prepend_nans=False, + ) +> array([[5, 1], + [5, 1], + [6, 1], + [6, 1], + [6, 0]]) +``` +## License +[](https://tldrlegal.com/license/mit-license) +The software is distributed under MIT license. + +%prep +%autosetup -n numpy-ext-0.9.8 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-numpy-ext -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed Apr 12 2023 Python_Bot <Python_Bot@openeuler.org> - 0.9.8-1 +- Package Spec generated |
