Skip to content
Closed

- #505

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions deepdiff/delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,24 @@ def _deserializer(obj, safe_to_import=None):
for path, op_codes in result['_iterable_opcodes'].items():
_iterable_opcodes[path] = []
for op_code in op_codes:
_iterable_opcodes[path].append(
Opcode(
**op_code
if isinstance(op_code, list):
# Handle list format: [tag, t1_from, t1_to, t2_from, t2_to, old_values, new_values]
_iterable_opcodes[path].append(
Opcode(
tag=op_code[0],
t1_from_index=op_code[1],
t1_to_index=op_code[2],
t2_from_index=op_code[3],
t2_to_index=op_code[4],
old_values=op_code[5],
new_values=op_code[6]
)
)
else:
# Handle dict format
_iterable_opcodes[path].append(
Opcode(**op_code)
)
)
result['_iterable_opcodes'] = _iterable_opcodes
return result

Expand Down
6 changes: 3 additions & 3 deletions tests/test_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2436,9 +2436,9 @@ def test_list_of_alphabet_and_its_delta(self):
flat_rows = delta2.to_flat_rows()

expected_flat_rows = [
FlatDeltaRow(path=[3], action='values_changed', value='X', old_value='D', type=str, old_type=str, new_path=[2]),
FlatDeltaRow(path=[6], action='values_changed', value='Z', old_value='G', type=str, old_type=str),
FlatDeltaRow(path=[5], action='values_changed', value='Y', old_value='F', type=str, old_type=str),
FlatDeltaRow(path=[3], action=FlatDataAction.values_changed, value='X', old_value='D', type=str, old_type=str, new_path=[2]),
FlatDeltaRow(path=[6], action=FlatDataAction.values_changed, value='Z', old_value='G', type=str, old_type=str),
FlatDeltaRow(path=[5], action=FlatDataAction.values_changed, value='Y', old_value='F', type=str, old_type=str),
FlatDeltaRow(path=[], action=FlatDataAction.iterable_items_deleted, value=[], old_value=['A'], type=list, old_type=list, t1_from_index=0, t1_to_index=1, t2_from_index=0, t2_to_index=0),
FlatDeltaRow(path=[], action=FlatDataAction.iterable_items_equal, value=None, old_value=None, type=type(None), old_type=type(None), t1_from_index=1, t1_to_index=3, t2_from_index=0, t2_to_index=2),
FlatDeltaRow(path=[], action=FlatDataAction.iterable_items_replaced, value=['X'], old_value=['D', 'E', 'F', 'G'], type=list, old_type=list, t1_from_index=3, t1_to_index=7, t2_from_index=2, t2_to_index=3),
Expand Down