Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions flax/nnx/variablelib.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@ def __ror__(self, other) -> A:
other = other.value
return self.value.__ror__(other) # type: ignore

def __eq__(self, other) -> bool:
if isinstance(other, Variable):
other = other.value
return self.value.__eq__(other) # type: ignore

def __iadd__(self: V, other) -> V:
raise NotImplementedError(
'In-place operations are no longer supported for Variable.\n'
Expand Down
1 change: 1 addition & 0 deletions tests/nnx/variable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def test_binary_ops(self):
result = v1 + v2

self.assertEqual(result, 5)
self.assertFalse(v1 == v2)

v1[...] += v2

Expand Down
Loading