mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-04 12:45:06 +08:00
MAINT: Fail fast on unsupported dtypes.
This commit is contained in:
@@ -8,8 +8,9 @@ from unittest import TestCase
|
||||
from zipline.errors import (
|
||||
DTypeNotSpecified,
|
||||
InputTermNotAtomic,
|
||||
InvalidDType,
|
||||
NotDType,
|
||||
TermInputsNotSpecified,
|
||||
UnsupportedDType,
|
||||
WindowLengthNotSpecified,
|
||||
)
|
||||
from zipline.pipeline import Factor, Filter, TermGraph
|
||||
@@ -19,6 +20,7 @@ from zipline.pipeline.term import AssetExists, NotSpecified
|
||||
from zipline.pipeline.expression import NUMEXPR_MATH_FUNCS
|
||||
from zipline.utils.numpy_utils import (
|
||||
bool_dtype,
|
||||
complex128_dtype,
|
||||
datetime64ns_dtype,
|
||||
float64_dtype,
|
||||
int64_dtype,
|
||||
@@ -332,9 +334,15 @@ class ObjectIdentityTestCase(TestCase):
|
||||
with self.assertRaises(DTypeNotSpecified):
|
||||
SomeFactorNoDType()
|
||||
|
||||
with self.assertRaises(InvalidDType):
|
||||
with self.assertRaises(NotDType):
|
||||
SomeFactor(dtype=1)
|
||||
|
||||
with self.assertRaises(NoDefaultMissingValue):
|
||||
SomeFactor(dtype=int64_dtype)
|
||||
|
||||
with self.assertRaises(UnsupportedDType):
|
||||
SomeFactor(dtype=complex128_dtype)
|
||||
|
||||
def test_latest_on_different_dtypes(self):
|
||||
factor_dtypes = (int64_dtype, float64_dtype, datetime64ns_dtype)
|
||||
for column in TestingDataSet.columns:
|
||||
@@ -350,11 +358,10 @@ class ObjectIdentityTestCase(TestCase):
|
||||
# property of correctly handling `NaN`.
|
||||
self.assertIs(column.missing_value, column.latest.missing_value)
|
||||
|
||||
def test_failure_timing_on_bad_missing_values(self):
|
||||
def test_failure_timing_on_bad_dtypes(self):
|
||||
|
||||
# Just constructing a bad column shouldn't fail.
|
||||
Column(dtype=int64_dtype)
|
||||
|
||||
with self.assertRaises(NoDefaultMissingValue) as e:
|
||||
class BadDataSet(DataSet):
|
||||
bad_column = Column(dtype=int64_dtype)
|
||||
@@ -367,6 +374,13 @@ class ObjectIdentityTestCase(TestCase):
|
||||
)
|
||||
)
|
||||
|
||||
Column(dtype=complex128_dtype)
|
||||
with self.assertRaises(UnsupportedDType):
|
||||
class BadDataSetComplex(DataSet):
|
||||
bad_column = Column(dtype=complex128_dtype)
|
||||
float_column = Column(dtype=float64_dtype)
|
||||
int_column = Column(dtype=int64_dtype, missing_value=3)
|
||||
|
||||
|
||||
class SubDataSetTestCase(TestCase):
|
||||
def test_subdataset(self):
|
||||
|
||||
Reference in New Issue
Block a user