From 62289645754f7974098d5a4a5410725886c435e3 Mon Sep 17 00:00:00 2001 From: Albert Zeyer Date: Mon, 22 Nov 2021 11:14:46 +0100 Subject: [PATCH] DimensionTag equality docs #634 --- returnn/tf/util/data.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/returnn/tf/util/data.py b/returnn/tf/util/data.py index 6540564a2..5dec156e1 100644 --- a/returnn/tf/util/data.py +++ b/returnn/tf/util/data.py @@ -470,10 +470,15 @@ def is_equal(self, other, ignore_feature_dim=False, allow_same_feature_dim=False undefined_matches=False, derived_matches=False): """ Compares self to other for equality. + Note that the default behavior is very restrictive. Use functions such as :func:`get_all_dimension_tags` or :func:`get_existing_tag_from_collection` to explicitly specify the behavior for the comparison. + Also note that the definition is slightly ad-hoc for some cases, + and might potentially change in the future. + https://github.com/rwth-i6/returnn/issues/634 + :param DimensionTag other: :param bool ignore_feature_dim: :param bool allow_same_feature_dim: @@ -540,6 +545,7 @@ def __eq__(self, other): """ :param DimensionTag other: :rtype: bool + :return: :func:`is_equal` with default options """ if not isinstance(other, DimensionTag): return False @@ -553,6 +559,10 @@ def __ne__(self, other): return not (self == other) def __hash__(self): + """ + :rtype: int + :return: hash, matching to :func:`__eq__` + """ # This must match the behavior in __eq__, which is is_equal with default options. # I.e. different hash implies not equal (but same hash not necessarily equal). if self.is_batch_dim():