-
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.
test: add unittest for grouping operator features
- Loading branch information
Showing
2 changed files
with
87 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from elastica.modules.feature_group import FeatureGroupFIFO | ||
|
||
|
||
def test_add_ids(): | ||
feature_group = FeatureGroupFIFO() | ||
feature_group.append_id(1) | ||
feature_group.append_id(2) | ||
feature_group.append_id(3) | ||
|
||
assert feature_group._operator_ids == [id(1), id(2), id(3)] | ||
|
||
|
||
def test_add_operators(): | ||
feature_group = FeatureGroupFIFO() | ||
feature_group.append_id(1) | ||
feature_group.add_operators(1, [1, 2, 3]) | ||
feature_group.append_id(2) | ||
feature_group.add_operators(2, [4, 5, 6]) | ||
feature_group.append_id(3) | ||
feature_group.add_operators(3, [7, 8, 9]) | ||
|
||
assert feature_group._operator_collection == [[1, 2, 3], [4, 5, 6], [7, 8, 9]] | ||
assert feature_group._operator_ids == [id(1), id(2), id(3)] | ||
|
||
feature_group.append_id(4) | ||
feature_group.add_operators(4, [10, 11, 12]) | ||
|
||
assert feature_group._operator_collection == [ | ||
[1, 2, 3], | ||
[4, 5, 6], | ||
[7, 8, 9], | ||
[10, 11, 12], | ||
] | ||
assert feature_group._operator_ids == [id(1), id(2), id(3), id(4)] | ||
|
||
|
||
def test_grouping(): | ||
feature_group = FeatureGroupFIFO() | ||
feature_group.append_id(1) | ||
feature_group.add_operators(1, [1, 2, 3]) | ||
feature_group.append_id(2) | ||
feature_group.add_operators(2, [4, 5, 6]) | ||
feature_group.append_id(3) | ||
feature_group.add_operators(3, [7, 8, 9]) | ||
|
||
assert list(feature_group) == [1, 2, 3, 4, 5, 6, 7, 8, 9] | ||
|
||
feature_group.append_id(4) | ||
feature_group.add_operators(4, [10, 11, 12]) | ||
|
||
assert list(feature_group) == [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] | ||
|
||
feature_group.append_id(1) | ||
feature_group.add_operators(1, [13, 14, 15]) | ||
|
||
assert list(feature_group) == [1, 2, 3, 13, 14, 15, 4, 5, 6, 7, 8, 9, 10, 11, 12] |