Skip to content

NCubeInterior equality ignores parametric bounds, and is inconsistent with its hash #198

Description

@yguclu

Two NCubeInterior objects with the same name but different parametric bounds compare equal, but they have different hashes. This breaks Python's requirement that a == b implies hash(a) == hash(b).

Reproduced with SymPDE 0.20.0:

from sympde.topology import Square

P = Square('P', bounds1=(0, 1), bounds2=(0, 1)).interior
Q = Square('P', bounds1=(0, 2), bounds2=(0, 1)).interior

P.min_coords, P.max_coords      # ((0.0, 0.0), (1.0, 1.0))
Q.min_coords, Q.max_coords      # ((0.0, 0.0), (2.0, 1.0))

P == Q                          # True: equality ignores the bounds
hash(P) == hash(Q)              # False: sets disagree with ==

P._hashable_content() returns only ('P',), so == compares names only, while the hash depends on other data as well.

Expected

Patches with different bounds compare unequal, and __eq__ and __hash__ agree. Including min_coords and max_coords in _hashable_content would probably fix both.

Context

In PSYDAC we need to check that a user-given domain matches the domain stored in a geometry file. Because of this bug we have to compare the bounds explicitly.

Activity

  1. added theissue type on Oct 6, 2026
  2. FrederikSchnack commented on Oct 6, 2026

    @FrederikSchnack
    Contributor

    I just checked with the changes in #193 , there both return false. In these changes, a lot of the hashing is changed.

  3. linked a pull request that will close this issueUpgrade SymPy #193on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

help wantedExtra attention is needed

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions