-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: expand synchronize operation order to be determined in the or…
…der of the specification
- Loading branch information
Showing
6 changed files
with
118 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Callable | ||
from elastica.typing import OperatorType | ||
|
||
from collection.abc import Iterable | ||
|
||
import itertools | ||
|
||
|
||
class FeatureGroupFIFO(Iterable): | ||
def __init__(self): | ||
self._operator_collection: list[list[OperatorType]] = [] | ||
self._operator_ids: list[int] = [] | ||
|
||
def __iter__(self) -> Callable[[...], None]: | ||
if not self._operator_collection: | ||
raise RuntimeError("Feature group is not instantiated.") | ||
operator_chain = itertools.chain(self._operator_collection) | ||
for operator in operator_chain: | ||
yield operator | ||
|
||
def append_id(self, feature): | ||
self._operator_ids.append(id(feature)) | ||
self._operator_collection.append([]) | ||
|
||
def add_operators(self, feature, operators: list[OperatorType]): | ||
idx = self._operator_idx.index(feature) | ||
self._operator_collection[idx].extend(operators) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters