Skip to content

Structural v/s symbolic equality for SymPy tests #602

@Saransh-cpp

Description

@Saransh-cpp

#581 raises the question of structural (x == y) v/s symbolic (simplify(x - y) == 0 or Eq(x, y)) equality. Even though symbolic equality would be easier to maintain in the longer run, it would be better to use the structural equality wherever possible to be more strict as -

Originally posted by @Saransh-cpp in #581 (review)

Tests failing without being mathematically wrong is bad IMO, since they will sooner or later fail with sympy updates (as is the case now from 1.13.1 -> 1.14.0). Hence I prefer symbolic comparison.

In fact it is quite similar to checking floating points by an epsilon range, since the backend computation can change, but the result is still right (wrt. the scope).

Originally posted by @APN-Pucky in #581 (comment)

Thanks! My comment behind using structural equality was because the "symbolic" nature of our compute functions will solely be tested by SymPy once Python 3.8 is removed from GH Actions; hence, we would want these tests to be strict (unless we find another way - #531). But at the same time, I don't think this strictness is actually adding anything to the test suite - the symbolic equality will test the exact same thing but in a more flexible way.

Given that we use structural equality everywhere in the tests, I have reverted to keep using that for now. However, I will open an issue to discuss this further (and possibly change all equalities in the tests in the future).

Originally posted by @Saransh-cpp in #581 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    testsMore or better tests are needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions