GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — continous refactor · FOSSAware/deepdiff@666599e

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • deepdiff
    • deephash.py
    • delta.py
    • diff.py
    • distance.py
    • helper.py
    • model.py
    • serialization.py
  • tests
    • test_delta.py
    • test_diff_tree.py
    • test_distance.py
    • test_helper.py
    • test_ignore_order.py
    • test_serialization.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎deepdiff/deephash.py‎

Copy file name to clipboardExpand all lines: deepdiff/deephash.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,15 @@ def get(self, key, default=None, extract_index=0):
230230
It can extract the hash for a given key that is already calculated when extract_index=0
231231
or the count of items that went to building the object whenextract_index=1.
232232
"""
233-
return self._get(self.hashes, key, default=default, extract_index=extract_index)
233+
return self.get_key(self.hashes, key, default=default, extract_index=extract_index)
234234

235235
@staticmethod
236-
def _get(hashes, key, default=None, extract_index=0):
236+
def get_key(hashes, key, default=None, extract_index=0):
237+
"""
238+
get_key method for the hashes dictionary.
239+
It can extract the hash for a given key that is already calculated when extract_index=0
240+
or the count of items that went to building the object whenextract_index=1.
241+
"""
237242
try:
238243
result = DeepHash._getitem(hashes, key, extract_index=extract_index)
239244
except KeyError:
Collapse file

‎deepdiff/delta.py‎

Copy file name to clipboardExpand all lines: deepdiff/delta.py
+7-4Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ def __init__(self, diff=None, delta_path=None, mutate=False, verify_symmetry=Fal
109109
self.raise_errors = raise_errors
110110
self.log_errors = log_errors
111111
self.numpy_used = self.diff.pop('numpy_used', False)
112+
self.reset()
112113

113114
def __repr__(self):
114115
return "<Delta: {}>".format(short_repr(self.diff, max_length=100))
@@ -117,7 +118,6 @@ def reset(self):
117118
self.post_process_paths_to_convert = {}
118119

119120
def __add__(self, other):
120-
self.reset()
121121
if isinstance(other, numbers) and self.numpy_used:
122122
raise DeltaNumpyOperatorOverrideError(DELTA_NUMPY_OPERATOR_OVERRIDE_MSG)
123123
if self.mutate:
@@ -142,6 +142,7 @@ def __add__(self, other):
142142
other = self.root
143143
# removing the reference to other
144144
del self.root
145+
self.reset()
145146
return other
146147

147148
__radd__ = __add__
@@ -416,18 +417,20 @@ def _do_ignore_order(self):
416417
"""
417418
fixed_indexes = self.diff.get('iterable_items_added_at_indexes', {})
418419
remove_indexes = self.diff.get('iterable_items_removed_at_indexes', {})
419-
import pytest; pytest.set_trace()
420+
# import pytest; pytest.set_trace()
420421
paths = set(fixed_indexes.keys()) | set(remove_indexes.keys())
421422
for path in paths:
422423
# In the case of ignore_order reports, we are pointing to the container object.
423424
# Thus we add a [0] to the elements so we can get the required objects and discard what we don't need.
424425
_, 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()
427429
# TODO: this needs to be changed to use deephash so any item can be in this set even if not hashable.
428430
fixed_indexes_values = set(fixed_indexes_per_path.values())
429431

430432
new_obj = []
433+
# Numpy's NdArray does not like the bool function.
431434
if isinstance(obj, np_ndarray):
432435
there_are_old_items = obj.size > 0
433436
else:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.