%global _empty_manifest_terminate_build 0 Name: python-pydivsufsort Version: 0.0.6 Release: 1 Summary: String algorithms License: MIT URL: https://github.com/louisabraham/pydivsufsort Source0: https://mirrors.nju.edu.cn/pypi/web/packages/e4/90/b48a1cc00a2de0d216bc4ae81baa0a7580b624e11a1d6ccf3d77c12301a6/pydivsufsort-0.0.6.tar.gz Requires: python3-wheel Requires: python3-numpy %description [![PyPI version](https://badge.fury.io/py/pydivsufsort.svg)](https://badge.fury.io/py/pydivsufsort) [![Build Status](https://travis-ci.com/louisabraham/pydivsufsort.svg?branch=master)](https://travis-ci.org/louisabraham/pydivsufsort) [![Coverage](https://codecov.io/gh/louisabraham/pydivsufsort/branch/master/graph/badge.svg)](https://codecov.io/gh/louisabraham/pydivsufsort) # `pydivsufsort`: bindings to libdivsufsort `pydivsufsort` prebuilds `libdivsufsort` as a shared library and includes it in a Python package with bindings. **Features**: - bindings to `divsufsort` that return numpy arrays - handle almost any integer data type (e.g. `int64`) and not only `char` - additional string algorithms ## Installation On Linux, macOS and Windows: ``` python -m pip install pydivsufsort ``` We provide precompiled wheels for common systems using `cibuildwheel`, and a source distribution for Unix systems. Manual compilation on Windows might require some tweaking, please create an issue. ## Usage ### Using String Inputs ```python import numpy as np from pydivsufsort import divsufsort, kasai string_inp = "banana$" string_suffix_array = divsufsort(string_inp) string_lcp_array = kasai(string_inp, string_suffix_array) print(string_suffix_array, string_lcp_array) # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0] ``` ### Using Integer Inputs ```python import numpy as np from pydivsufsort import divsufsort, kasai string_inp = "banana$" # Convert the string input to integers first int_inp = np.unique(np.array(list(string_inp)), return_inverse=True)[1] int_suffix_array = divsufsort(int_inp) int_lcp_array = kasai(int_inp, int_suffix_array) print(int_suffix_array, int_lcp_array) # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0] ``` ### Using Multiple Sentinel Characters Witin A String ```python import numpy as np from pydivsufsort import divsufsort, kasai sentinel_inp = "a$banana#and@a*bandana+" sentinel_suffix_array = divsufsort(sentinel_inp) sentinel_lcp_array = kasai(sentinel_inp, sentinel_suffix_array) print(sentinel_suffix_array, sentinel_lcp_array) # [ 8 1 14 22 12 7 0 13 21 5 19 3 9 16 2 15 11 18 6 20 4 10 17] [0 0 0 0 0 1 1 1 1 3 3 2 3 0 3 0 1 0 2 2 1 2 0] ``` ## Testing ``` pytest ``` ## Technical details (for performance tweaks) `libdivsufsort` is compiled in both 32 and 64 bits, as [the 32 bits version is faster](https://github.com/y-256/libdivsufsort/issues/21). `pydivsufsort` automatically chooses to use the 32 bits version when possible (aka when the input size is less than `2**31-1`). For best performance, use contiguous arrays. If you have a sliced array, pydivsufsort converts it automatically with [`numpy.ascontiguousarray`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html). The precompiled libraries use OpenMP. You can disable it by setting the env variable `OMP_NUM_THREADS=1`, and it will yield the same performance as the version compiled without OpenMP The original `libdivsufsort` only supports char as the base type. `pydivsufsort` can handle arrays of any integer type (even signed), by encoding each element as multiple chars, which makes the computation slower. If your values use an integer type that is bigger than required, but they span over a small contiguous range, `pydivsufsort` will automatically change their type (see [#6](https://github.com/louisabraham/pydivsufsort/issues/6)). ## Acknowledgements - [Yuta Mori](https://github.com/y-256) for writing [libdivsufsort](https://github.com/y-256/libdivsufsort) - [Sean Law](http://seanlaw.github.io/) for initiating this project and contributing %package -n python3-pydivsufsort Summary: String algorithms Provides: python-pydivsufsort BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-pip BuildRequires: python3-cffi BuildRequires: gcc BuildRequires: gdb %description -n python3-pydivsufsort [![PyPI version](https://badge.fury.io/py/pydivsufsort.svg)](https://badge.fury.io/py/pydivsufsort) [![Build Status](https://travis-ci.com/louisabraham/pydivsufsort.svg?branch=master)](https://travis-ci.org/louisabraham/pydivsufsort) [![Coverage](https://codecov.io/gh/louisabraham/pydivsufsort/branch/master/graph/badge.svg)](https://codecov.io/gh/louisabraham/pydivsufsort) # `pydivsufsort`: bindings to libdivsufsort `pydivsufsort` prebuilds `libdivsufsort` as a shared library and includes it in a Python package with bindings. **Features**: - bindings to `divsufsort` that return numpy arrays - handle almost any integer data type (e.g. `int64`) and not only `char` - additional string algorithms ## Installation On Linux, macOS and Windows: ``` python -m pip install pydivsufsort ``` We provide precompiled wheels for common systems using `cibuildwheel`, and a source distribution for Unix systems. Manual compilation on Windows might require some tweaking, please create an issue. ## Usage ### Using String Inputs ```python import numpy as np from pydivsufsort import divsufsort, kasai string_inp = "banana$" string_suffix_array = divsufsort(string_inp) string_lcp_array = kasai(string_inp, string_suffix_array) print(string_suffix_array, string_lcp_array) # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0] ``` ### Using Integer Inputs ```python import numpy as np from pydivsufsort import divsufsort, kasai string_inp = "banana$" # Convert the string input to integers first int_inp = np.unique(np.array(list(string_inp)), return_inverse=True)[1] int_suffix_array = divsufsort(int_inp) int_lcp_array = kasai(int_inp, int_suffix_array) print(int_suffix_array, int_lcp_array) # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0] ``` ### Using Multiple Sentinel Characters Witin A String ```python import numpy as np from pydivsufsort import divsufsort, kasai sentinel_inp = "a$banana#and@a*bandana+" sentinel_suffix_array = divsufsort(sentinel_inp) sentinel_lcp_array = kasai(sentinel_inp, sentinel_suffix_array) print(sentinel_suffix_array, sentinel_lcp_array) # [ 8 1 14 22 12 7 0 13 21 5 19 3 9 16 2 15 11 18 6 20 4 10 17] [0 0 0 0 0 1 1 1 1 3 3 2 3 0 3 0 1 0 2 2 1 2 0] ``` ## Testing ``` pytest ``` ## Technical details (for performance tweaks) `libdivsufsort` is compiled in both 32 and 64 bits, as [the 32 bits version is faster](https://github.com/y-256/libdivsufsort/issues/21). `pydivsufsort` automatically chooses to use the 32 bits version when possible (aka when the input size is less than `2**31-1`). For best performance, use contiguous arrays. If you have a sliced array, pydivsufsort converts it automatically with [`numpy.ascontiguousarray`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html). The precompiled libraries use OpenMP. You can disable it by setting the env variable `OMP_NUM_THREADS=1`, and it will yield the same performance as the version compiled without OpenMP The original `libdivsufsort` only supports char as the base type. `pydivsufsort` can handle arrays of any integer type (even signed), by encoding each element as multiple chars, which makes the computation slower. If your values use an integer type that is bigger than required, but they span over a small contiguous range, `pydivsufsort` will automatically change their type (see [#6](https://github.com/louisabraham/pydivsufsort/issues/6)). ## Acknowledgements - [Yuta Mori](https://github.com/y-256) for writing [libdivsufsort](https://github.com/y-256/libdivsufsort) - [Sean Law](http://seanlaw.github.io/) for initiating this project and contributing %package help Summary: Development documents and examples for pydivsufsort Provides: python3-pydivsufsort-doc %description help [![PyPI version](https://badge.fury.io/py/pydivsufsort.svg)](https://badge.fury.io/py/pydivsufsort) [![Build Status](https://travis-ci.com/louisabraham/pydivsufsort.svg?branch=master)](https://travis-ci.org/louisabraham/pydivsufsort) [![Coverage](https://codecov.io/gh/louisabraham/pydivsufsort/branch/master/graph/badge.svg)](https://codecov.io/gh/louisabraham/pydivsufsort) # `pydivsufsort`: bindings to libdivsufsort `pydivsufsort` prebuilds `libdivsufsort` as a shared library and includes it in a Python package with bindings. **Features**: - bindings to `divsufsort` that return numpy arrays - handle almost any integer data type (e.g. `int64`) and not only `char` - additional string algorithms ## Installation On Linux, macOS and Windows: ``` python -m pip install pydivsufsort ``` We provide precompiled wheels for common systems using `cibuildwheel`, and a source distribution for Unix systems. Manual compilation on Windows might require some tweaking, please create an issue. ## Usage ### Using String Inputs ```python import numpy as np from pydivsufsort import divsufsort, kasai string_inp = "banana$" string_suffix_array = divsufsort(string_inp) string_lcp_array = kasai(string_inp, string_suffix_array) print(string_suffix_array, string_lcp_array) # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0] ``` ### Using Integer Inputs ```python import numpy as np from pydivsufsort import divsufsort, kasai string_inp = "banana$" # Convert the string input to integers first int_inp = np.unique(np.array(list(string_inp)), return_inverse=True)[1] int_suffix_array = divsufsort(int_inp) int_lcp_array = kasai(int_inp, int_suffix_array) print(int_suffix_array, int_lcp_array) # [6 5 3 1 0 4 2] [0 1 3 0 0 2 0] ``` ### Using Multiple Sentinel Characters Witin A String ```python import numpy as np from pydivsufsort import divsufsort, kasai sentinel_inp = "a$banana#and@a*bandana+" sentinel_suffix_array = divsufsort(sentinel_inp) sentinel_lcp_array = kasai(sentinel_inp, sentinel_suffix_array) print(sentinel_suffix_array, sentinel_lcp_array) # [ 8 1 14 22 12 7 0 13 21 5 19 3 9 16 2 15 11 18 6 20 4 10 17] [0 0 0 0 0 1 1 1 1 3 3 2 3 0 3 0 1 0 2 2 1 2 0] ``` ## Testing ``` pytest ``` ## Technical details (for performance tweaks) `libdivsufsort` is compiled in both 32 and 64 bits, as [the 32 bits version is faster](https://github.com/y-256/libdivsufsort/issues/21). `pydivsufsort` automatically chooses to use the 32 bits version when possible (aka when the input size is less than `2**31-1`). For best performance, use contiguous arrays. If you have a sliced array, pydivsufsort converts it automatically with [`numpy.ascontiguousarray`](https://docs.scipy.org/doc/numpy/reference/generated/numpy.ascontiguousarray.html). The precompiled libraries use OpenMP. You can disable it by setting the env variable `OMP_NUM_THREADS=1`, and it will yield the same performance as the version compiled without OpenMP The original `libdivsufsort` only supports char as the base type. `pydivsufsort` can handle arrays of any integer type (even signed), by encoding each element as multiple chars, which makes the computation slower. If your values use an integer type that is bigger than required, but they span over a small contiguous range, `pydivsufsort` will automatically change their type (see [#6](https://github.com/louisabraham/pydivsufsort/issues/6)). ## Acknowledgements - [Yuta Mori](https://github.com/y-256) for writing [libdivsufsort](https://github.com/y-256/libdivsufsort) - [Sean Law](http://seanlaw.github.io/) for initiating this project and contributing %prep %autosetup -n pydivsufsort-0.0.6 %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-pydivsufsort -f filelist.lst %dir %{python3_sitearch}/* %files help -f doclist.lst %{_docdir}/* %changelog * Fri May 05 2023 Python_Bot - 0.0.6-1 - Package Spec generated