https://en.wikipedia.org/wiki/List_of_mathematical_symbols#Symbols_based_on_equality
https://en.wikipedia.org/wiki/Tilde#As_a_relational_operator - https://patsy.readthedocs.io/en/latest/formulas.html <https://patsy.readthedocs.io/en/latest/formulas.html> https://docs.python.org/3/reference/expressions.html#index-61 > The unary ~ (invert) operator yields the bitwise inversion of its integer argument. The bitwise inversion of x is defined as -(x+1). It only applies to integral numbers. https://numpy.org/doc/stable/reference/generated/numpy.allclose.html > If the following equation is element-wise True, then allclose returns True. > > absolute(a - b) <= (atol + rtol * absolute(b)) > > The above equation is not symmetric in a and b, so that allclose(a, b) might be different from allclose(b, a) in some rare cases. > > The comparison of a and b uses standard broadcasting, which means that a and b need not have the same shape in order for allclose(a, b) to evaluate to True. The same is true for equal but not array_equal. Presumably, tensor comparisons have different broadcasting rules but allclosr is similarly defined. > “Euclid’s first common notion is this,” says Lincoln in the film, “Things which are equal to the same thing are equal to each other. That’s a rule of mathematical reasoning. It’s true because it works. Has done and always will do. In his book, Euclid says this is ‘self-evident.’ You see, there it is, even in that 2,000-year-old book of mechanical law. It is a self-evident truth that things which are equal to the same thing are equal to each other.” On Sun, Jun 14, 2020, 8:43 AM Sebastian M. Ernst <er...@pleiszenburg.de> wrote: > Hi all, > > after just having typed tons of `math.isclose` (see PEP 485 [1]) and > `numpy.isclose` calls (while basically using their default tolerances > most of the time), I was wondering whether it makes sense to add a > matching operator. > > "Strict" equality check as usual: `a == b` > "Approximate" equality check: > -> `a ?= b` (similar to `!=`) > -> `a ~= b` (my preference) > -> `a === b` (just to confuse the JS crowd) > > A corresponding method could for instance be named `__ic__` (Is Close), > `__ae__` (Approximate Equal) or `__ce__` (Close Equal). > > It's such a common problem when dealing with floating point numbers or > similar data types (arrays of floats, float-based geometries etc). An > operator of this kind would make many people's lives much easier, I bet. > I have overloaded the modulo operator in some test code and it actually > helps a lot to make some logic more readable. > > Best regards, > Sebastian > > > 1: https://www.python.org/dev/peps/pep-0485/ > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/KD45D5JKJS72PF7NRHC4MMQQEOB7MLRX/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/WMRW3PGCO2KLWVWMDNF7KU5Z6DZDQ5NF/ Code of Conduct: http://python.org/psf/codeofconduct/