Comments (5)
@bwest-at-xometry I'm finally back and catching up with the tickets.
Interesting point you bring up regarding the definition of the significant digit. I think it might be a good idea to give the user the flexibility to pass their definition of "significant digits". What do you think about that?
The math.isclose is tricky since we don't know how "close" the numbers are during the hashing process. The hashing process is used when ignore_order=True
and during that process, the significant digits are used to transform the numbers and then hash them.
from deepdiff.
Flexibility would be great.
from deepdiff.
I will try to address this in v4.2.0 whenever I can...
Or if you have time, please feel free to make a PR. What I'm imagining is maybe a parameter called: significant_digits_format
and people can pass their own functions. For example the default one is:
lambda x, significant_digits: ("{:.%sf}" % significant_digits).format(x)
And then you could pass:
def scientific_significant_digits_format(x, significant_digits):
return lambda x, significant_digits: ("{:.%se}" % (significant_digits - 1)).format(x)
DeepDiff(t1, t2, significant_digits_format=scientific_significant_digits_format)
That gives the full control to the user.
If you make the PR, please have that function passed into the DeepHash too.
Thanks!
from deepdiff.
forgot to tag you! @bwest-at-xometry
from deepdiff.
@bwest-at-xometry This feature is now published. There is the number_format_notation
now that you can set to e
for scientific notation. Also for power users the number_to_string_fun
is introduced.
https://deepdiff.readthedocs.io/en/stable/diff.html
from deepdiff.
Related Issues (20)
- Unsupported Operation: readline + Debug Feature HOT 2
- iterable_compare_func not working properly HOT 4
- 6.4.0 - AttributeError: 'NoneType' object has no attribute '__version__' HOT 1
- 6.4.0 importing deepdiff results in none type error HOT 5
- Simple typo in test paths generation. HOT 1
- Delta.__add__ breaks with esoteric dict keys HOT 1
- 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
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.