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
13 changed files
with
429 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import numpy as np | ||
|
||
from zipline.testing.predicates import assert_equal | ||
from zipline.pipeline import Classifier, Factor, Filter | ||
from zipline.utils.numpy_utils import float64_dtype, int64_dtype | ||
|
||
from .base import BasePipelineTestCase | ||
|
||
|
||
class WithAlias(object): | ||
|
||
def test_alias(self): | ||
f = self.Term() | ||
alias = f.alias('ayy lmao') | ||
|
||
f_values = np.random.RandomState(5).randn(5, 5) | ||
|
||
self.check_terms( | ||
terms={ | ||
'f_alias': alias, | ||
}, | ||
expected={ | ||
'f_alias': f_values, | ||
}, | ||
initial_workspace={f: f_values}, | ||
mask=self.build_mask(np.ones((5, 5))), | ||
) | ||
|
||
def test_repr(self): | ||
assert_equal( | ||
repr(self.Term().alias('ayy lmao')), | ||
"Aliased%s(Term(...), name='ayy lmao')" % ( | ||
self.Term.__base__.__name__, | ||
), | ||
) | ||
|
||
def test_short_repr(self): | ||
for name in ('a', 'b'): | ||
assert_equal( | ||
self.Term().alias(name).short_repr(), | ||
name, | ||
) | ||
|
||
|
||
class TestFactorAlias(WithAlias, BasePipelineTestCase): | ||
class Term(Factor): | ||
dtype = float64_dtype | ||
inputs = () | ||
window_length = 0 | ||
|
||
|
||
class TestFilterAlias(WithAlias, BasePipelineTestCase): | ||
class Term(Filter): | ||
inputs = () | ||
window_length = 0 | ||
|
||
|
||
class TestClassifierAlias(WithAlias, BasePipelineTestCase): | ||
class Term(Classifier): | ||
dtype = int64_dtype | ||
inputs = () | ||
window_length = 0 | ||
missing_value = -1 |
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
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.