Check for Equality between Domain Instances#

import minterpy as mp
import numpy as np

Two instances of Domain may be checked for equality in value via the == operator as demonstrated in this guide.

Two instances of Domain are equal in value if and only if:

  • the underlying bounds have the same shape (i.e., the same number of spatial dimensions)

  • all the corresponding bounds, including:

    • User bounds: The rectangular bounds of the domain as specified by the user during instance construction, e.g., \([0, 5] \times [1, 2]\).

    • Internal bounds: The bounds of the reference domain used internally by Minterpy. Currently they are always set to \([-1, 1]^m\).

Example: Two equal domains#

The two domains below are equal:

  • \(\Omega_1 = [2, 3] \times [4, 5]\)

  • \(\Omega_2 = [2, 3] \times [4, 5]\)

dom_1 = mp.Domain(np.array([[2, 3], [4, 5]]))
dom_2 = mp.Domain(np.array([[2, 3], [4, 5]]))

To check the equality between two instances, use the == operator. So:

dom_1 == dom_2  # True
True

Note that == checks for equality in value, not object identity. Even though the two instances are equal in value, they are distinct instances, as confirmed below

dom_1 is dom_2  # False
False

Example: Unequal domains - differing bounds#

The two domains below have the same spatial dimension but differ in the bounds of the second dimension:

  • \(\Omega_3 = [1, 2] \times [4, 5]\)

  • \(\Omega_4 = [1, 2] \times [4, 6]\)

dom_3 = mp.Domain(np.array([[1, 2], [4, 5]]))
dom_4 = mp.Domain(np.array([[1, 2], [4, 6]]))
dom_3 == dom_4  # False
False

Example: Unequal domains - differing spatial dimensions#

The two domains below have the same bounds up to the common dimension but differ in their spatial dimension:

  • \(\Omega_5 = [1, 2] \times [3, 4] \times [5, 6]\)

  • \(\Omega_6 = [1, 2] \times [3, 4]\)

dom_5 = mp.Domain(np.array([[1, 2], [3, 4], [5, 6]]))
dom_6 = mp.Domain(np.array([[1, 2], [3, 4]]))
dom_5 == dom_6  # False
False