Giter Site home page Giter Site logo

Comments (6)

seperman avatar seperman commented on August 15, 2024

Once we properly implement the delta operator for DeepDiff then you can get the delta of a DeepDiff result from the original object which should give you what is the same between the 2.

from deepdiff.

lhriley avatar lhriley commented on August 15, 2024

🧟

Since it seems that Delta is now implemented here in the future, and this issue is still open:

I'm trying to understand how to get similarity out of Delta, and I'm just not wrapping my head around it.

Any tips on how one might accomplish getting "unchanged values" out of a diff between two dictionaries?

Partial solution, but doesn't cover deeply nested values well: #203

from deepdiff.

seperman avatar seperman commented on August 15, 2024

@lhriley You are correct. What I wrote in 2017 doesn't make sense. The delta object is only holding the difference between the 2 objects.

from deepdiff.

seperman avatar seperman commented on August 15, 2024

I need to think about how this makes sense. For example, if in a nested dictionary, one value is changed, what do we report as similar?

t1 = {"key": {"a": {"key2": "val2", "key3": "val3", "key4": "val4"}}}
t1 = {"key": {"a": {"key2": "val2", "key3": "DIFFERENT!!", "key4": "val4"}}}

Do you expected something like this?

root["key"]["a"]["key2"]
root["key"]["a"]["key4"]

from deepdiff.

lhriley avatar lhriley commented on August 15, 2024

@seperman that's a good question. I guess that I would expect a dict like object that goes as deep as the detected change.

Given:

t1 = {"key": {"a": {"key2": "val2", "key3": "val3", "key4": "val4"}}}
t2 = {"key": {"a": {"key2": "val2", "key3": "DIFFERENT!!", "key4": "val4"}}}

I could call:

delta.unchanged => {"key": {"a": {"key2": "val2", "key4": "val4"}}}
delta.changed => {"key": {"a": {"key3": "DIFFERENT!!"}}}

Then in my code I could do something like:

if delta.changed:
   print("values changed!")
   print(delta.changed)
   print(delta.diff)
   # do something about the change

if delta.unchanged:
   print("values didn't change. skipping.")
   print(delta.unchanged)
  # nothing to do for unchanged values

from deepdiff.

lukjak avatar lukjak commented on August 15, 2024

Hi,

I would definitely use the feature as well. My scenario is two objects with some overlap, where I would like to make the second object a "pure delta" - without any elements already present in the first one.

I would expect a result to look identically to a diff, just like with comparison done with equal operator instead of non-equal.

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.