-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
25 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,39 @@ | ||
""" | ||
Test the connection example from the documentation | ||
""" | ||
import os | ||
import sys | ||
|
||
sys.path.insert(1, os.path.join(sys.path[0], "../..")) | ||
|
||
|
||
def test_constant_column(): | ||
from opteryx.models.relation_schema import ConstantColumn | ||
from opteryx.constants.attribute_types import OPTERYX_TYPES | ||
|
||
col = ConstantColumn(name="numbers", data_type=OPTERYX_TYPES.INTEGER, length=100, value=0.75) | ||
val = col.materialize() | ||
|
||
print(col) | ||
print(val) | ||
|
||
assert sum(val) == 75 | ||
|
||
|
||
def test_dictionary_column(): | ||
from opteryx.models.relation_schema import DictionaryColumn | ||
from opteryx.constants.attribute_types import OPTERYX_TYPES | ||
|
||
values = [1, 2, 3, 4, 5, 4, 3, 2, 1, 2, 3, 4, 3, 2, 1, 2, 3] | ||
col = DictionaryColumn(name="numbers", data_type=OPTERYX_TYPES.INTEGER, values=values) | ||
val = col.materialize() | ||
|
||
assert len(col.dictionary) == len(set(col.dictionary)) | ||
assert all(val[i] == v for i, v in enumerate(values)) | ||
|
||
|
||
if __name__ == "__main__": # pragma: no cover | ||
test_constant_column() | ||
test_dictionary_column() | ||
|
||
print("✅ okay") |