Giter Club home page Giter Club logo

Comments (1)

seperman avatar seperman commented on June 8, 2024

Hi @kfirc
Thanks for reporting this.
What is happening here is that exclude_regex_paths is not working properly with report_repetition:

In [1]: from deepdiff import DeepDiff, Delta
   ...:
   ...: d1 = {'a': [{'id': 1}, {'id': 2}, {'id': 3}]}
   ...: d2 = {'a': [{'id': 1}, {'id': 2}, {'id': 3}, {'id': 4}]}
   ...:
   ...: deep_diff_result = DeepDiff(d1, d2, exclude_regex_paths=[r"(?=root.*\['id'\])"], ignore_order=True, report_re
   ...: petition=True)
   ...:

In [2]: deep_diff_result
Out[2]:
{'repetition_change': {"root['a'][0]": {'old_repeat': 3,
   'new_repeat': 4,
   'old_indexes': [0, 1, 2],
   'new_indexes': [0, 1, 2, 3],
   'value': {'id': 1}}}}

In [3]: deep_diff_result = DeepDiff(d1, d2, ignore_order=True, report_repetition=True)

In [4]: deep_diff_result
Out[4]: {'iterable_item_added': {"root['a'][3]": {'id': 4}}

What delta object gets in your case is that {'id': 1} needs to be repeated 4 times. That's why you get the unexpected result.

from deepdiff.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.