wavelet-matrix 2.0.8__cp313-cp313t-manylinux_2_24_ppc64le.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ from .wavelet_matrix import *
2
+
3
+ __doc__ = wavelet_matrix.__doc__
4
+ if hasattr(wavelet_matrix, "__all__"):
5
+ __all__ = wavelet_matrix.__all__
@@ -0,0 +1,64 @@
1
+ from typing import Iterable
2
+
3
+ class WaveletMatrix:
4
+ def __init__(self, data: Iterable[int]) -> None: ...
5
+ def __getitem__(self, index: int) -> int: ...
6
+ def __len__(self) -> int: ...
7
+ def __str__(self) -> str: ...
8
+ def __repr__(self) -> str: ...
9
+ def __copy__(self) -> WaveletMatrix: ...
10
+ def __deepcopy__(self, memo) -> WaveletMatrix: ...
11
+ def values(self) -> list[int]: ...
12
+ def access(self, index: int) -> int: ...
13
+ def rank(self, value: int, end: int) -> int: ...
14
+ def select(self, value: int, kth: int) -> int | None: ...
15
+ def quantile(self, start: int, end: int, kth: int) -> int: ...
16
+ def topk(self, start: int, end: int, k: int | None = None) -> list[dict[str, int]]: ...
17
+ def range_sum(self, start: int, end: int) -> int: ...
18
+ def range_intersection(
19
+ self, start1: int, end1: int, start2: int, end2: int
20
+ ) -> list[dict[str, int]]: ...
21
+ def range_freq(
22
+ self, start: int, end: int, lower: int | None = None, upper: int | None = None
23
+ ) -> int: ...
24
+ def range_list(
25
+ self, start: int, end: int, lower: int | None = None, upper: int | None = None
26
+ ) -> list[dict[str, int]]: ...
27
+ def range_maxk(self, start: int, end: int, k: int | None = None) -> list[dict[str, int]]: ...
28
+ def range_mink(self, start: int, end: int, k: int | None = None) -> list[dict[str, int]]: ...
29
+ def prev_value(self, start: int, end: int, upper: int | None = None) -> int | None: ...
30
+ def next_value(self, start: int, end: int, lower: int | None = None) -> int | None: ...
31
+
32
+ class DynamicWaveletMatrix:
33
+ def __init__(self, data: Iterable[int], max_bit: int | None = None) -> None: ...
34
+ def __getitem__(self, index: int) -> int: ...
35
+ def __setitem__(self, index: int, value: int) -> None: ...
36
+ def __len__(self) -> int: ...
37
+ def __str__(self) -> str: ...
38
+ def __repr__(self) -> str: ...
39
+ def __copy__(self) -> DynamicWaveletMatrix: ...
40
+ def __deepcopy__(self, memo) -> DynamicWaveletMatrix: ...
41
+ def values(self) -> list[int]: ...
42
+ def access(self, index: int) -> int: ...
43
+ def rank(self, value: int, end: int) -> int: ...
44
+ def select(self, value: int, kth: int) -> int | None: ...
45
+ def quantile(self, start: int, end: int, kth: int) -> int: ...
46
+ def topk(self, start: int, end: int, k: int | None = None) -> list[dict[str, int]]: ...
47
+ def range_sum(self, start: int, end: int) -> int: ...
48
+ def range_intersection(
49
+ self, start1: int, end1: int, start2: int, end2: int
50
+ ) -> list[dict[str, int]]: ...
51
+ def range_freq(
52
+ self, start: int, end: int, lower: int | None = None, upper: int | None = None
53
+ ) -> int: ...
54
+ def range_list(
55
+ self, start: int, end: int, lower: int | None = None, upper: int | None = None
56
+ ) -> list[dict[str, int]]: ...
57
+ def range_maxk(self, start: int, end: int, k: int | None = None) -> list[dict[str, int]]: ...
58
+ def range_mink(self, start: int, end: int, k: int | None = None) -> list[dict[str, int]]: ...
59
+ def prev_value(self, start: int, end: int, upper: int | None = None) -> int | None: ...
60
+ def next_value(self, start: int, end: int, lower: int | None = None) -> int | None: ...
61
+ def max_bit(self) -> int: ...
62
+ def insert(self, index: int, value: int) -> None: ...
63
+ def remove(self, index: int) -> int: ...
64
+ def update(self, index: int, value: int) -> int: ...
File without changes
@@ -0,0 +1,259 @@
1
+ Metadata-Version: 2.4
2
+ Name: wavelet-matrix
3
+ Version: 2.0.8
4
+ Classifier: Intended Audience :: Developers
5
+ Classifier: Intended Audience :: Science/Research
6
+ Classifier: Intended Audience :: Information Technology
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Programming Language :: Python :: 3.14
15
+ Classifier: Programming Language :: Python :: Implementation :: CPython
16
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
19
+ Classifier: Topic :: Scientific/Engineering :: Mathematics
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: pdoc>=16.0 ; extra == 'dev'
22
+ Requires-Dist: ruff>=0.14 ; extra == 'dev'
23
+ Requires-Dist: pytest>=7.0 ; extra == 'test'
24
+ Requires-Dist: pytest-benchmark>=4.0 ; extra == 'test'
25
+ Provides-Extra: dev
26
+ Provides-Extra: test
27
+ License-File: LICENSE
28
+ Summary: High-performance indexed sequence data structure powered by Rust, supporting fast rank/select and range queries.
29
+ Keywords: wavelet matrix,data structure,algorithm,sequence index,rank,select,quantile,top-k,range query,dynamic update,indexing,succinct
30
+ Author: Koki Watanabe
31
+ Requires-Python: >=3.9
32
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
33
+ Project-URL: documentation, https://math-hiyoko.github.io/wavelet-matrix
34
+ Project-URL: homepage, https://github.com/math-hiyoko/wavelet-matrix
35
+ Project-URL: repository, https://github.com/math-hiyoko/wavelet-matrix
36
+
37
+ # Wavelet Matrix
38
+
39
+ [![CI](https://github.com/math-hiyoko/wavelet-matrix/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/math-hiyoko/wavelet-matrix/actions/workflows/CI.yml)
40
+ [![codecov](https://codecov.io/gh/math-hiyoko/wavelet-matrix/graph/badge.svg?token=TXBR7MF2CP)](https://codecov.io/gh/math-hiyoko/wavelet-matrix)
41
+ ![PyPI - Version](https://img.shields.io/pypi/v/wavelet-matrix)
42
+ ![PyPI - License](https://img.shields.io/pypi/l/wavelet-matrix)
43
+ ![PyPI - PythonVersion](https://img.shields.io/pypi/pyversions/wavelet-matrix)
44
+ ![PyPI - Implementation](https://img.shields.io/pypi/implementation/wavelet-matrix)
45
+ ![PyPI - Types](https://img.shields.io/pypi/types/wavelet-matrix)
46
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/wavelet-matrix?period=total&units=INTERNATIONAL_SYSTEM&left_color=GRAY&right_color=GREEN&left_text=PyPI%20downloads)](https://pepy.tech/projects/wavelet-matrix)
47
+ ![PyPI - Format](https://img.shields.io/pypi/format/wavelet-matrix)
48
+ ![Rust](https://img.shields.io/badge/powered%20by-Rust-orange)
49
+ ![Unsafe](https://img.shields.io/badge/unsafe-0-success)
50
+
51
+
52
+ High-performance indexed sequence structure powered by Rust, supporting fast rank/select and range queries with optional dynamic updates.
53
+
54
+ - PyPI: https://pypi.org/project/wavelet-matrix
55
+ - Document: https://math-hiyoko.github.io/wavelet-matrix
56
+ - Repository: https://github.com/math-hiyoko/wavelet-matrix
57
+
58
+
59
+ ## Quick Start
60
+
61
+ ```bash
62
+ $ pip install wavelet-matrix
63
+ ```
64
+
65
+ ### WaveletMatrix
66
+ ```python
67
+ >>> from wavelet_matrix import WaveletMatrix
68
+ >>>
69
+ >>> # Create a WaveletMatrix
70
+ >>> data = [5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0]
71
+ >>> wm = WaveletMatrix(data)
72
+ >>> wm
73
+ WaveletMatrix([5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0])
74
+ ```
75
+
76
+ #### Count occurrences (rank)
77
+ ```python
78
+ >>> # Count of 5 in the range [0, 9)
79
+ >>> wm.rank(value=5, end=9)
80
+ 4
81
+ ```
82
+
83
+ #### Find position (select)
84
+ ```python
85
+ >>> # Find the index of 4th occurrence of value 5
86
+ >>> wm.select(value=5, kth=4)
87
+ 6
88
+ ```
89
+
90
+ #### Find k-th smallest (quantile)
91
+ ```python
92
+ >>> # Find 8th smallest value in the range [2, 12)
93
+ >>> wm.quantile(start=2, end=12, kth=8)
94
+ 5
95
+ ```
96
+
97
+ #### List top-k highest frequent values (topk)
98
+ ```python
99
+ >>> # List values in [1, 10) with the top-2 highest frequencies.
100
+ >>> wm.topk(start=1, end=10, k=2)
101
+ [{'value': 5, 'count': 3}, {'value': 1, 'count': 2}]
102
+ ```
103
+
104
+ #### Sum values in a range (range_sum)
105
+ ```python
106
+ >>> # Sum of elements in the range [2, 8).
107
+ >>> wm.range_sum(start=2, end=8)
108
+ 24
109
+ ```
110
+
111
+ #### List intersection of two ranges (range_intersection)
112
+ ```python
113
+ >>> # List the intersection of two ranges [0, 6) and [6, 11).
114
+ >>> wm.range_intersection(start1=0, end1=6, start2=6, end2=11)
115
+ [{'value': 1, 'count1': 1, 'count2': 1}, {'value': 5, 'count1': 3, 'count2': 2}]
116
+ ```
117
+
118
+ #### Count values in a range (range_freq)
119
+ ```python
120
+ >>> # Count values c in the range [1, 9) such that 4 <= c < 6.
121
+ >>> wm.range_freq(start=1, end=9, lower=4, upper=6)
122
+ 4
123
+ ```
124
+
125
+ #### List values in a range (range_list)
126
+ ```python
127
+ >>> # List values c in the range [1, 9) such that 4 <= c < 6.
128
+ >>> wm.range_list(start=1, end=9, lower=4, upper=6)
129
+ [{'value': 4, 'count': 1}, {'value': 5, 'count': 3}]
130
+ ```
131
+
132
+ #### List top-k maximum values (range_maxk)
133
+ ```python
134
+ >>> # List values in [1, 9) with the top-2 maximum values.
135
+ >>> wm.range_maxk(start=1, end=9, k=2)
136
+ [{'value': 6, 'count': 1}, {'value': 5, 'count': 3}]
137
+ ```
138
+
139
+ #### List top-k minimum values (range_mink)
140
+ ```python
141
+ >>> # List values in [1, 9) with the top-2 minimum values.
142
+ >>> wm.range_mink(start=1, end=9, k=2)
143
+ [{'value': 1, 'count': 2}, {'value': 2, 'count': 1}]
144
+ ```
145
+
146
+ #### Get the maximun value (prev_value)
147
+ ```python
148
+ >>> # Get the maximum value c in the range [1, 9) such that c < 7.
149
+ >>> wm.prev_value(start=1, end=9, upper=7)
150
+ 6
151
+ ```
152
+
153
+ #### Get the minimun value (next_value)
154
+ ```python
155
+ >>> # Get the minimum value c in the range [1, 9) such that 4 <= c.
156
+ >>> wm.next_value(start=1, end=9, lower=4)
157
+ 4
158
+ ```
159
+
160
+ ### Dynamic Wavelet Matrix
161
+ ```python
162
+ >>> from wavelet_matrix import DynamicWaveletMatrix
163
+ >>>
164
+ >>> # Create a DynamicWaveletMatrix
165
+ >>> # max_bit sets the maximum bit-width of stored values (auto-inferred if omitted).
166
+ >>> data = [5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0]
167
+ >>> dwm = DynamicWaveletMatrix(data, max_bit=4)
168
+ >>> dwm
169
+ DynamicWaveletMatrix([5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
170
+ ```
171
+
172
+ #### Insert value (insert)
173
+ ```python
174
+ >>> dwm
175
+ DynamicWaveletMatrix([5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
176
+ >>> # Inserts 8 at index 4.
177
+ >>> # The bit width of the new value must not exceed max_bit.
178
+ >>> dwm.insert(index=4, value=8)
179
+ >>> dwm
180
+ DynamicWaveletMatrix([5, 4, 5, 5, 8, 2, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
181
+ ```
182
+
183
+ #### Remove value (remove)
184
+ ```python
185
+ >>> dwm
186
+ DynamicWaveletMatrix([5, 4, 5, 5, 8, 2, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
187
+ >>> # Remove the value at index 4.
188
+ >>> dwm.remove(index=4)
189
+ 8
190
+ >>> dwm
191
+ DynamicWaveletMatrix([5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
192
+ ```
193
+
194
+ #### Update value (update)
195
+ ```python
196
+ >>> dwm
197
+ DynamicWaveletMatrix([5, 4, 5, 5, 2, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
198
+ >>> # Update the value at index 4 to 5
199
+ >>> # The bit width of the new value must not exceed max_bit.
200
+ >>> dwm.update(index=4, value=5)
201
+ 2
202
+ >>> dwm
203
+ DynamicWaveletMatrix([5, 4, 5, 5, 5, 1, 5, 6, 1, 3, 5, 0], max_bit=4)
204
+ ```
205
+
206
+ ## Safety
207
+
208
+ This Python package is powered by safe Rust.
209
+ The Rust implementation forbids `unsafe` code.
210
+
211
+ ## Development
212
+
213
+ ### Running Tests
214
+
215
+ ```bash
216
+ $ pip install -e ".[test]"
217
+
218
+ # Cargo test
219
+ $ cargo test --all --release
220
+
221
+ # Run tests
222
+ $ pytest --benchmark-skip
223
+
224
+ # Run benchmarks
225
+ $ pytest --benchmark-only
226
+ ```
227
+
228
+ ### Formating Code
229
+ ```bash
230
+ $ pip install -e ".[dev]"
231
+
232
+ # Format Rust code
233
+ $ cargo fmt
234
+
235
+ # Format Python code
236
+ $ ruff format
237
+ ```
238
+
239
+ ### Generating Docs
240
+ ```bash
241
+ $ pdoc wavelet_matrix \
242
+ --output-directory docs \
243
+ --no-search \
244
+ --no-show-source \
245
+ --docformat markdown \
246
+ --footer-text "© 2025 Koki Watanabe"
247
+ ```
248
+
249
+ ## References
250
+
251
+ - Francisco Claude, Gonzalo Navarro, Alberto Ordóñez,
252
+ The wavelet matrix: An efficient wavelet tree for large alphabets,
253
+ Information Systems,
254
+ Volume 47,
255
+ 2015,
256
+ Pages 15-32,
257
+ ISSN 0306-4379,
258
+ https://doi.org/10.1016/j.is.2014.06.002.
259
+
@@ -0,0 +1,8 @@
1
+ wavelet_matrix/__init__.py,sha256=bY2bBHUr5LI7lsksSDxTm_ZQY6vJGBV63B5ryuJVa-U,139
2
+ wavelet_matrix/__init__.pyi,sha256=ZhfsOeBaakGgxmBuCTPYIOsdUPw15Inu2Iilq6DIzRw,3372
3
+ wavelet_matrix/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ wavelet_matrix/wavelet_matrix.cpython-313t-powerpc64le-linux-gnu.so,sha256=o9JDQPpcdAsg0-tBpdsQhOsEGyVdJ_bjq-ZQAO-Pt_o,2068288
5
+ wavelet_matrix-2.0.8.dist-info/METADATA,sha256=POiuiW9ljyxqKmMJe40JPLkGqbdu1RxdudTRxDRWveM,7928
6
+ wavelet_matrix-2.0.8.dist-info/WHEEL,sha256=ibpoa1gtAg_6nsVteV0UD7YRgd5BL3LHL3lSEEo-s54,111
7
+ wavelet_matrix-2.0.8.dist-info/licenses/LICENSE,sha256=RLItjifD2pjpecDwt0BdQ7bFR6517amHYtkEENvrPac,1060
8
+ wavelet_matrix-2.0.8.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.11.2)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313t-manylinux_2_24_ppc64le
@@ -0,0 +1,7 @@
1
+ Copyright 2025 Koki Watanabe
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.