Skip to content

Commit

Permalink
Consistent order in all_attributes()
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Holl committed Oct 18, 2024
1 parent 433b86c commit f30da56
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions phiml/math/_magic_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ def variable_values(obj) -> Tuple[str, ...]:
return obj.__value_attrs__() # this takes care of dataclasses as well


def all_attributes(obj, assert_any=False) -> Set[str]:
def all_attributes(obj, assert_any=False) -> Sequence[str]:
if not isinstance(obj, PhiTreeNode):
raise ValueError(f"Not a PhiTreeNode: {type(obj).__name__}")
result = set()
Expand All @@ -697,7 +697,7 @@ def all_attributes(obj, assert_any=False) -> Set[str]:
result.update([f.name for f in dataclasses.fields(obj)])
if assert_any:
assert result, f"{type(obj).__name__} is not a valid tree node because it has no tensor-like attributes."
return result
return tuple(sorted(result))


def replace(obj: PhiTreeNodeType, **updates) -> PhiTreeNodeType:
Expand Down

0 comments on commit f30da56

Please sign in to comment.