Comments (11)
Hello. Thank you for letting us know about why you need this feature. I am working on a plugin system for DeepDiff to allow easier customization of DeepDiff for such use cases. I will keep you posted. Thank you for your patience.
from deepdiff.
Interesting. I wonder whether this should be done by DeepDiff or it is a use case that should be done outside DeepDiff.
from deepdiff.
It would have been helpful for me saving me from having to do a bunch of unicode casts and worse some ugly BSON related casts in my tests when a python equality comparison is happy to ignore the type difference as long as the values match. Obviously it would have to be optional since DeepDiff being fussy about type is a great feature at other times.
from deepdiff.
I agree, particularly be able to ignore unicode vs. string optionally.
from deepdiff.
I also agree. I find necessary to compare dicts without comparing the types of the values
from deepdiff.
Any thoughts on this? Would definitely be helpful, happy to lend a hand if you have an implementation in mind.
from deepdiff.
I agree, first I'v thought that the exclude_type argument would satisfy this requirement but it totally excludes the validation process for any given item which applies to the given types.
from deepdiff.
Would like to add another use-case:
In dicts there are several ways to declare a key/value pair is unset. Examples could be: zero-length string, empty dictionary or NoneType. In those cases, I would like to have the option, that just the value change is reported but not the type change. Reasoning is, that during parsing a document and generating the dict - the parser might not know the data-type for unset values. So it would be best guess of the parser to use any of the implementations above. Deepdiff should have the option ignore such type changes (just in the case of unset values)...
Examples to encode <a/>
(unset value) as a python dict:
x1 = {u'a': None}
x2 = {u'a': u''}
x3 = {u'a': {}}
x4 = {u'a': []}
To compare against:
z1={u'a': u'#myvalue#'}
z2={u'a': {u'b': u'c'}}
So instead of:
>>> deepdiff.DeepDiff(x1,z1, view='patch')
{'type_changes': {"root['a']": {'new_type': <type 'unicode'>, 'old_type': <type 'NoneType'>, 'old_value': None, 'new_value': u'#myvalue#'}}}
Result should be:
>>> deepdiff.DeepDiff(x1,z1, view='patch')
{'values_changed': {"root['a']": {'new_value': u'#myvalue#', 'old_value': None}}}
Alternatively of the tool might report:
>>> deepdiff.DeepDiff(x1,z1, view='patch')
{'values_added': {"root['a']": u'#myvalue#'}}
from deepdiff.
I need this too! Can help if you need me to, too :)
I want to diff 2 objects, I just need the difference in values and not in the type.
from deepdiff.
sorry to comment in an old issue.
Is this feature supported?
from deepdiff.
Hi @kapilt @ruiruige @nemaniarjun @wisotzky @itaykatz @flomotlik @aexvir @phoebebright @finnhughes
We have ignore_type_in_groups
now. I think that should solve most of the problems that are brought up in this ticket.
You can read about it here: https://deepdiff.readthedocs.io/en/latest/diff.html
Closing this ticket finally!
from deepdiff.
Related Issues (20)
- Function `parse_path` doesn't exist but is referenced in the docs. HOT 1
- Keys containing "__a__" at the beginning will be ignored. HOT 1
- Diff does not work for attributes of a class that inherits from dict or collections.UserDict HOT 4
- DeepDiff raises decimal exception when using significant digits HOT 3
- Can't compare dicts with both single and double quotes in keys HOT 3
- Inconsistent Behavior with math_epsilon and ignore_order HOT 1
- max_diffs doesn't use ignore_nan_inequality flag
- Wrong diff on list of strings HOT 3
- DeepDiff fails when dictionary keys are unrepresentable and exclude_regex_paths is not None
- Errors with dictionary_item_removed and dictionary_item_added HOT 3
- Error on Delta With None Key and Removed Item from List
- Need to be able to see full path on all outputs HOT 1
- Error when subtracting Delta from a dictionary HOT 4
- Documentation on how to consume keys HOT 2
- Error after comparing: Can not produce a hash (type datetime.date doesn't define __round__ method) HOT 1
- parse_path() cannot parse a path HOT 4
- Is there a way to systematically cycle through all corresponding attributes that haven't changed? HOT 1
- support compre string as float specify precision HOT 1
- Error when comparing two nested dicts with 2 added fields HOT 5
- why exclude_regex_paths dont work with ignore_order HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deepdiff.