Skip to content

Commit 2df57c1

Browse files
committed
DimensionTag equality docs
#634
1 parent 76ce5e0 commit 2df57c1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

returnn/tf/util/data.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,10 +470,15 @@ def is_equal(self, other, ignore_feature_dim=False, allow_same_feature_dim=False
470470
undefined_matches=False, derived_matches=False):
471471
"""
472472
Compares self to other for equality.
473+
473474
Note that the default behavior is very restrictive.
474475
Use functions such as :func:`get_all_dimension_tags` or :func:`get_existing_tag_from_collection`
475476
to explicitly specify the behavior for the comparison.
476477
478+
Also note that the definition is slightly ad-hoc for some cases,
479+
and might potentially change in the future.
480+
https://github.com/rwth-i6/returnn/issues/634
481+
477482
:param DimensionTag other:
478483
:param bool ignore_feature_dim:
479484
:param bool allow_same_feature_dim:
@@ -540,6 +545,7 @@ def __eq__(self, other):
540545
"""
541546
:param DimensionTag other:
542547
:rtype: bool
548+
:return: :func:`is_equal` with default options
543549
"""
544550
if not isinstance(other, DimensionTag):
545551
return False
@@ -553,6 +559,10 @@ def __ne__(self, other):
553559
return not (self == other)
554560

555561
def __hash__(self):
562+
"""
563+
:rtype: int
564+
:return: hash, matching to :func:`__eq__`
565+
"""
556566
# This must match the behavior in __eq__, which is is_equal with default options.
557567
# I.e. different hash implies not equal (but same hash not necessarily equal).
558568
if self.is_batch_dim():

0 commit comments

Comments
 (0)