Skip to content

Commit 0e1f109

Browse files
committed
+1
1 parent 9f0701e commit 0e1f109

2 files changed

Lines changed: 294 additions & 294 deletions

File tree

analysis/code_analysis.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def encode(self, chunks: dict[int, int]) -> tuple[list[int], int]:
169169
for i, fio in chunks.items():
170170
delta = i - last_chunk_index
171171
ops += self.encode_entry(delta, fio)
172-
last_chunk_index = i
172+
last_chunk_index = i + 1
173173

174174
return ops, self.WIDTH * len(ops)
175175

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

194195

@@ -200,8 +201,8 @@ def test_scheme_consecutive():
200201
chunks = {0: 1, 1: 2, 2: 3}
201202
ops, _ = sch.encode(chunks)
202203
assert ops[0] == 0 * sch.VALUE_MOD + 1
203-
assert ops[1] == 1 * sch.VALUE_MOD + 2
204-
assert ops[2] == 1 * sch.VALUE_MOD + 3
204+
assert ops[1] == 0 * sch.VALUE_MOD + 2
205+
assert ops[2] == 0 * sch.VALUE_MOD + 3
205206

206207
assert sch.decode(ops) == chunks
207208

@@ -213,7 +214,7 @@ def test_scheme_skip_one():
213214
chunks = {0: 1, 2: 3}
214215
ops, _ = sch.encode(chunks)
215216
assert ops[0] == 0 * sch.VALUE_MOD + 1
216-
assert ops[1] == 2 * sch.VALUE_MOD + 3
217+
assert ops[1] == 1 * sch.VALUE_MOD + 3
217218

218219
assert sch.decode(ops) == chunks
219220

@@ -224,16 +225,15 @@ def test_scheme_skip_first():
224225
chunks = {1: 2, 2: 3}
225226
ops, _ = sch.encode(chunks)
226227
assert ops[0] == 1 * sch.VALUE_MOD + 2
227-
assert ops[1] == 1 * sch.VALUE_MOD + 3
228+
assert ops[1] == 0 * sch.VALUE_MOD + 3
228229

229230
assert sch.decode(ops) == chunks
230231

231232

232233
def test_scheme_sparse_values():
233234
sch = Scheme("", 8)
234-
gap = [Chunk(0, [], False)]
235235

236-
chunks = {0: 1, 2: 2, 4: 3}
236+
chunks = {0: 1, 3: 2, 6: 3}
237237
ops, _ = sch.encode(chunks)
238238
assert ops[0] == 0 * sch.VALUE_MOD + 1
239239
assert ops[1] == 2 * sch.VALUE_MOD + 2
@@ -248,8 +248,8 @@ def test_scheme_skip_entry_0():
248248
chunks = {0: 1, 130: 3}
249249
ops, _ = sch.encode(chunks)
250250
assert ops[0] == 0 * sch.VALUE_MOD + 1
251-
# assert ops[1] == sch.SKIP_ONLY + 127
252-
# assert ops[2] == 0 * sch.VALUE_MOD + 3
251+
assert ops[1] == sch.SKIP_ONLY + 127
252+
assert ops[2] == 0 * sch.VALUE_MOD + 3
253253

254254
assert sch.decode(ops) == chunks
255255

0 commit comments

Comments
 (0)