From 67d546f00059f800589ab56e76f2524407ad9e59 Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Thu, 10 Dec 2015 16:21:46 -0500 Subject: [PATCH] MAINT: Use an enum for the AdjustmentKind. --- zipline/lib/adjustment.pyx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zipline/lib/adjustment.pyx b/zipline/lib/adjustment.pyx index 9d1a7c2f..748c3025 100644 --- a/zipline/lib/adjustment.pyx +++ b/zipline/lib/adjustment.pyx @@ -10,9 +10,11 @@ ctypedef object DatetimeIndex_t ctypedef object Timestamp_t # Adjustment kinds. -MULTIPLY = 0 -ADD = 1 -OVERWRITE = 2 +cpdef enum AdjustmentKind: + MULTIPLY = 0 + ADD = 1 + OVERWRITE = 2 + ADJUSTMENT_KIND_NAMES = { MULTIPLY: 'MULTIPLY', ADD: 'ADD', @@ -35,7 +37,7 @@ def _is_datetime(object value): return isinstance(value, (datetime64, Timestamp)) -cpdef choose_adjustment_type(int adjustment_kind, object value): +cpdef choose_adjustment_type(AdjustmentKind adjustment_kind, object value): """ Make an adjustment object of the type appropriate for the given kind and value. @@ -78,7 +80,7 @@ cpdef make_adjustment_from_indices(Py_ssize_t first_row, Py_ssize_t last_row, Py_ssize_t first_column, Py_ssize_t last_column, - int adjustment_kind, + AdjustmentKind adjustment_kind, object value): """ Make an Adjustment object from row/column indices into a baseline array. @@ -95,7 +97,7 @@ cpdef make_adjustment_from_labels(DatetimeIndex_t dates_index, Timestamp_t start_date, Timestamp_t end_date, int asset_id, - int adjustment_kind, + AdjustmentKind adjustment_kind, object value): """ Make an Adjustment object from date/asset labels into a labelled baseline