@@ -109,6 +109,7 @@ def __init__(self, diff=None, delta_path=None, mutate=False, verify_symmetry=Fal |
109 | 109 | self.raise_errors = raise_errors |
110 | 110 | self.log_errors = log_errors |
111 | 111 | self.numpy_used = self.diff.pop('numpy_used', False) |
| 112 | + self.reset() |
112 | 113 |
|
113 | 114 | def __repr__(self): |
114 | 115 | return "<Delta: {}>".format(short_repr(self.diff, max_length=100)) |
@@ -117,7 +118,6 @@ def reset(self): |
117 | 118 | self.post_process_paths_to_convert = {} |
118 | 119 |
|
119 | 120 | def __add__(self, other): |
120 | | - self.reset() |
121 | 121 | if isinstance(other, numbers) and self.numpy_used: |
122 | 122 | raise DeltaNumpyOperatorOverrideError(DELTA_NUMPY_OPERATOR_OVERRIDE_MSG) |
123 | 123 | if self.mutate: |
@@ -142,6 +142,7 @@ def __add__(self, other): |
142 | 142 | other = self.root |
143 | 143 | # removing the reference to other |
144 | 144 | del self.root |
| 145 | + self.reset() |
145 | 146 | return other |
146 | 147 |
|
147 | 148 | __radd__ = __add__ |
@@ -416,18 +417,20 @@ def _do_ignore_order(self): |
416 | 417 | """ |
417 | 418 | fixed_indexes = self.diff.get('iterable_items_added_at_indexes', {}) |
418 | 419 | remove_indexes = self.diff.get('iterable_items_removed_at_indexes', {}) |
419 | | - import pytest; pytest.set_trace() |
| 420 | + # import pytest; pytest.set_trace() |
420 | 421 | paths = set(fixed_indexes.keys()) | set(remove_indexes.keys()) |
421 | 422 | for path in paths: |
422 | 423 | # In the case of ignore_order reports, we are pointing to the container object. |
423 | 424 | # Thus we add a [0] to the elements so we can get the required objects and discard what we don't need. |
424 | 425 | _, parent, parent_to_obj_elem, parent_to_obj_action, obj, _, _ = self._get_elements_and_details("{}[0]".format(path)) |
425 | | - fixed_indexes_per_path = fixed_indexes.get(path, {}) |
426 | | - remove_indexes_per_path = remove_indexes.get(path, {}) |
| 426 | + # copying both these dictionaries since we don't want to mutate them. |
| 427 | + fixed_indexes_per_path = fixed_indexes.get(path, {}).copy() |
| 428 | + remove_indexes_per_path = remove_indexes.get(path, {}).copy() |
427 | 429 | # TODO: this needs to be changed to use deephash so any item can be in this set even if not hashable. |
428 | 430 | fixed_indexes_values = set(fixed_indexes_per_path.values()) |
429 | 431 |
|
430 | 432 | new_obj = [] |
| 433 | + # Numpy's NdArray does not like the bool function. |
431 | 434 | if isinstance(obj, np_ndarray): |
432 | 435 | there_are_old_items = obj.size > 0 |
433 | 436 | else: |
|