Skip to content

Commit 06d35e2

Browse files
oprypintensorflower-gardener
authored andcommitted
Automated Code Change
PiperOrigin-RevId: 852244325
1 parent 6426fd1 commit 06d35e2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

tensorflow_privacy/privacy/privacy_tests/membership_inference_attack/data_structures.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,21 @@ class AttackInputData:
316316
# treated as multilabel data.
317317
force_multilabel_data: bool = False
318318

319+
# Directly comparing members of the type `np.ndarray` can throw an error:
320+
# "The truth value of an array with more than one element is ambiguous."
321+
# So we bring back an explicit implementation of __eq__ like it was prior to
322+
# Python 3.13 in order work around this possibility.
323+
def __eq__(self, other):
324+
if self is other:
325+
return True
326+
if other.__class__ is self.__class__:
327+
return tuple(
328+
getattr(self, field.name) for field in dataclasses.fields(self)
329+
) == tuple(
330+
getattr(other, field.name) for field in dataclasses.fields(other)
331+
)
332+
return NotImplemented
333+
319334
@property
320335
def num_classes(self):
321336
if self.labels_train is None or self.labels_test is None:

0 commit comments

Comments
 (0)