Giter Site home page Giter Site logo

Comments (5)

seperman avatar seperman commented on July 16, 2024

@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.

bwest-at-xometry avatar bwest-at-xometry commented on July 16, 2024

Flexibility would be great.

from deepdiff.

seperman avatar seperman commented on July 16, 2024

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.

seperman avatar seperman commented on July 16, 2024

forgot to tag you! @bwest-at-xometry

from deepdiff.

seperman avatar seperman commented on July 16, 2024

@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)

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.