-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
cb11049
commit f11e978
Showing
7 changed files
with
241 additions
and
17 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,61 @@ | ||
import pytest | ||
from dataclasses import dataclass, field | ||
import blocks as bk | ||
|
||
|
||
def test_base_sampler(): | ||
|
||
class MySampler(bk.BaseSampler): | ||
pass | ||
|
||
with pytest.raises(TypeError): | ||
MySampler() | ||
|
||
|
||
def test_base_transformer(): | ||
|
||
class MyTransformer(bk.BaseTransformer): | ||
pass | ||
|
||
with pytest.raises(TypeError): | ||
MyTransformer() | ||
|
||
|
||
def test_base_transformer_check_kwargs(): | ||
|
||
class MyTransformer(bk.BaseTransformer): | ||
TRANSFORMERS = {'func1': 'a', 'func2': 'b'} | ||
|
||
def __init__(self, select: str, **kwargs): | ||
self.select = select | ||
self.kwargs = kwargs | ||
|
||
def __call__(cls): | ||
pass | ||
|
||
my_transformer = MyTransformer('func1') | ||
assert my_transformer.check_kwargs("hello", "hello") == None | ||
assert my_transformer.check_kwargs("func2", "b") == None | ||
with pytest.raises(ValueError): | ||
my_transformer.check_kwargs("func1", "a") | ||
|
||
my_transformer = MyTransformer('func1', a='a') | ||
assert my_transformer.check_kwargs("hello", "hello") == None | ||
assert my_transformer.check_kwargs("func2", "b") == None | ||
assert my_transformer.check_kwargs("func1", "a") == None | ||
|
||
|
||
def test_base_factor(): | ||
|
||
@dataclass | ||
class MyFactor(bk.BaseFactor): | ||
tags: list = field(default_factory=lambda: []) | ||
name: str = "" | ||
X: str = "" | ||
y: str = None | ||
market_feature: str = "" | ||
inputs: dict = field(default_factory=lambda: {}) | ||
outputs: dict = field(default_factory=lambda: {}) | ||
pipeline: tuple = field(default_factory=lambda: ()) | ||
|
||
assert MyFactor().__class__.__name__ == "MyFactor" |
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
Oops, something went wrong.