提交 c7a99b60 authored 作者: Virgile Andreani's avatar Virgile Andreani 提交者: Ricardo Vieira

Remove OrderedDict from graph/fg

上级 3b5bd372
"""A container for specifying and manipulating a graph with distinct inputs and outputs.""" """A container for specifying and manipulating a graph with distinct inputs and outputs."""
import time import time
from collections import OrderedDict, defaultdict from collections import defaultdict
from collections.abc import Iterable, Sequence from collections.abc import Iterable, Sequence
from typing import TYPE_CHECKING, Any, Literal, Union, cast from typing import TYPE_CHECKING, Any, Literal, Union, cast
...@@ -768,12 +768,12 @@ class FunctionGraph(MetaObject): ...@@ -768,12 +768,12 @@ class FunctionGraph(MetaObject):
""" """
assert isinstance(self._features, list) assert isinstance(self._features, list)
all_orderings: list[OrderedDict] = [] all_orderings: list[dict] = []
for feature in self._features: for feature in self._features:
if hasattr(feature, "orderings"): if hasattr(feature, "orderings"):
orderings = feature.orderings(self) orderings = feature.orderings(self)
if not isinstance(orderings, OrderedDict): if not isinstance(orderings, dict):
raise TypeError( raise TypeError(
"Non-deterministic return value from " "Non-deterministic return value from "
+ str(feature.orderings) + str(feature.orderings)
...@@ -794,7 +794,7 @@ class FunctionGraph(MetaObject): ...@@ -794,7 +794,7 @@ class FunctionGraph(MetaObject):
return all_orderings[0].copy() return all_orderings[0].copy()
else: else:
# If there is more than 1 ordering, combine them. # If there is more than 1 ordering, combine them.
ords: dict[Apply, list[Apply]] = OrderedDict() ords: dict[Apply, list[Apply]] = {}
for orderings in all_orderings: for orderings in all_orderings:
for node, prereqs in orderings.items(): for node, prereqs in orderings.items():
ords.setdefault(node, []).extend(prereqs) ords.setdefault(node, []).extend(prereqs)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论