MAINT: Rework event datasets.

- Refactored EventsLoader and BlazeEventsLoader to not require a
  subclass per dataset.  Instead, you now pass a map from columns to
  event fields directly to the EventsLoader constructor.

- Removed a large number of Quantopian-specific datasets and associated
  tests.

- Rewrote the core logic of EventsLoader and BlazeEventsLoader to share
  index calculations across multiple requested columns.

- Fixed a bug where event fields were incorrectly forward-filled when
  null values were present in an event.
This commit is contained in:
Scott Sanderson
2016-06-10 19:22:27 -04:00
parent 5a6b870cd5
commit bc302beec9
33 changed files with 780 additions and 3556 deletions
+41
View File
@@ -1,3 +1,4 @@
import datetime
from functools import partial
import inspect
@@ -339,6 +340,46 @@ def assert_adjustment_equal(result, expected, path=(), **kwargs):
)
@assert_equal.register(
(datetime.datetime, np.datetime64),
(datetime.datetime, np.datetime64),
)
def assert_timestamp_and_datetime_equal(result,
expected,
path=(),
msg='',
allow_datetime_coercions=False,
compare_nat_equal=True,
**kwargs):
"""
Branch for comparing python datetime (which includes pandas Timestamp) and
np.datetime64 as equal.
Returns raises unless ``allow_datetime_coercions`` is passed as True.
"""
assert allow_datetime_coercions or type(result) == type(expected), (
"%sdatetime types (%s, %s) don't match and "
"allow_datetime_coercions was not set.\n%s" % (
_fmt_msg(msg),
type(result),
type(expected),
_fmt_path(path),
)
)
result = pd.Timestamp(result)
expected = pd.Timestamp(result)
if compare_nat_equal and pd.isnull(result) and pd.isnull(expected):
return
assert_equal.dispatch(object, object)(
result,
expected,
path=path,
**kwargs
)
try:
# pull the dshape cases in
from datashape.util.testing import assert_dshape_equal