Class PyEquality
Python's == between the Python counterparts of .NET values (see PyBuiltins for the mapping),
which is how Gymnasium compares info dicts, metadata, spec kwargs and the values inside them: numbers of any
width compare by value (1 == 1.0 == True), dicts ignore insertion order, lists and tuples compare element by
element and never equal each other. A tuple is an ITuple or an exact object?[]
(Gym.NET's generic tuple, DR-13); a typed array or a list is a list.
public static class PyEquality
- Inheritance
-
PyEquality
- Inherited Members
Remarks
Arrays are the one deliberate deviation. In Python, == between arrays is element-wise and a dict comparison
then asks for the truth of the result, which raises ValueError for arrays of more than one element. Here two
arrays are equal when array_equal(NDArray, NDArray, bool) says so (same shape, equal elements, any
dtypes; NaN never equals NaN), so an Info holding arrays can still be compared. A 0-d array
is the NumPy scalar it stands for and compares as a number; a one-element array compared with a number compares
its element, as Python's truth test of a one-element array does.
Identity short-circuits, as in Python's container comparisons (PyObject_RichCompareBool): the same object
is equal to itself even when it is, or contains, a NaN.
Methods
AreEqual(object?, object?)
Python's left == right for the values' Python counterparts, with the array rule of the class remarks.
public static bool AreEqual(object? left, object? right)
Parameters
Returns
Remarks
A container that holds itself recurses without end; Python detects that and raises RecursionError,
which no Gymnasium comparison relies on.