Skip to content

Commit

Permalink
+1
Browse files Browse the repository at this point in the history
  • Loading branch information
chfast committed May 9, 2024
1 parent 9f0701e commit 0e1f109
Show file tree
Hide file tree
Showing 2 changed files with 294 additions and 294 deletions.
18 changes: 9 additions & 9 deletions analysis/code_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def encode(self, chunks: dict[int, int]) -> tuple[list[int], int]:
for i, fio in chunks.items():
delta = i - last_chunk_index
ops += self.encode_entry(delta, fio)
last_chunk_index = i
last_chunk_index = i + 1

return ops, self.WIDTH * len(ops)

Expand All @@ -189,6 +189,7 @@ def decode(self, ops: list[int]) -> dict[int, int]:
i += delta
m[i] = value
running_skip = 0 # FIXME: unit test missing
i += 1
return m


Expand All @@ -200,8 +201,8 @@ def test_scheme_consecutive():
chunks = {0: 1, 1: 2, 2: 3}
ops, _ = sch.encode(chunks)
assert ops[0] == 0 * sch.VALUE_MOD + 1
assert ops[1] == 1 * sch.VALUE_MOD + 2
assert ops[2] == 1 * sch.VALUE_MOD + 3
assert ops[1] == 0 * sch.VALUE_MOD + 2
assert ops[2] == 0 * sch.VALUE_MOD + 3

assert sch.decode(ops) == chunks

Expand All @@ -213,7 +214,7 @@ def test_scheme_skip_one():
chunks = {0: 1, 2: 3}
ops, _ = sch.encode(chunks)
assert ops[0] == 0 * sch.VALUE_MOD + 1
assert ops[1] == 2 * sch.VALUE_MOD + 3
assert ops[1] == 1 * sch.VALUE_MOD + 3

assert sch.decode(ops) == chunks

Expand All @@ -224,16 +225,15 @@ def test_scheme_skip_first():
chunks = {1: 2, 2: 3}
ops, _ = sch.encode(chunks)
assert ops[0] == 1 * sch.VALUE_MOD + 2
assert ops[1] == 1 * sch.VALUE_MOD + 3
assert ops[1] == 0 * sch.VALUE_MOD + 3

assert sch.decode(ops) == chunks


def test_scheme_sparse_values():
sch = Scheme("", 8)
gap = [Chunk(0, [], False)]

chunks = {0: 1, 2: 2, 4: 3}
chunks = {0: 1, 3: 2, 6: 3}
ops, _ = sch.encode(chunks)
assert ops[0] == 0 * sch.VALUE_MOD + 1
assert ops[1] == 2 * sch.VALUE_MOD + 2
Expand All @@ -248,8 +248,8 @@ def test_scheme_skip_entry_0():
chunks = {0: 1, 130: 3}
ops, _ = sch.encode(chunks)
assert ops[0] == 0 * sch.VALUE_MOD + 1
# assert ops[1] == sch.SKIP_ONLY + 127
# assert ops[2] == 0 * sch.VALUE_MOD + 3
assert ops[1] == sch.SKIP_ONLY + 127
assert ops[2] == 0 * sch.VALUE_MOD + 3

assert sch.decode(ops) == chunks

Expand Down
Loading

0 comments on commit 0e1f109

Please sign in to comment.