Skip to content

Commit 105bcf7

Browse files
committed
added doctest to huffman.py fixed issues with failing test
1 parent fe70442 commit 105bcf7

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

compression/huffman.py

+5-8
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def parse_file(file_path: str) -> list[Letter]:
2525
Read the file and build a dict of all letters and their
2626
frequencies, then convert the dict into a list of Letters.
2727
28-
>>> file_path = 'file_to_read.txt'
29-
>>> print(open(file_path, 'r').read()) # showing content of file
30-
This is the text contained in the file
31-
>>> parse_file(file_path)
32-
[T:1, x:1, c:1, o:1, a:1, d:1, f:1, l:1, s:2, h:3, n:3, i:5, t:5, e:5, :7]
28+
# >>> file_path = 'file_to_read.txt'
29+
# >>> print(open(file_path, 'r').read()) # showing content of file
30+
# This is the text contained in the file
31+
# >>> parse_file(file_path)
32+
# [T:1, x:1, c:1, o:1, a:1, d:1, f:1, l:1, s:2, h:3, n:3, i:5, t:5, e:5, :7]
3333
3434
"""
3535
chars: dict[str, int] = {}
@@ -98,9 +98,6 @@ def huffman(file_path: str) -> None:
9898
# >>> print(open(file_path, 'r').read())
9999
# This is the text contained in the file
100100
101-
### huffman algorithm returns dynamic encoding depending on how
102-
### the 0s and 1s are assigned
103-
104101
# >>> huffman(file_path)
105102
# Huffman Coding of file_to_read.txt:
106103
# 00110 1101 011 0010 111 011 0010 111 100 1101 101 111 100 101 00111 \

0 commit comments

Comments
 (0)