Skip to content

Commit 1e914d8

Browse files
committed
add readme with example
1 parent caf365f commit 1e914d8

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Installation
2+
============
3+
4+
pip install range-coder
5+
6+
7+
Example
8+
=======
9+
10+
```python
11+
from range_coder import RangeEncoder, RangeDecoder, prob_to_cum_freq
12+
13+
data = [2, 0, 1, 0, 0, 0, 1, 2, 2]
14+
prob = [0.5, 0.2, 0.3]
15+
cumFreq = prob_to_cum_freq(prob, resolution=128)
16+
17+
# encode data
18+
encoder = RangeEncoder(filepath)
19+
encoder.encode(data, cumFreq)
20+
encoder.close()
21+
22+
# decode data
23+
decoder = RangeDecoder(filepath)
24+
dataRec = decoder.decode(len(data), cumFreq)
25+
decoder.close()
26+
```

0 commit comments

Comments
 (0)