From 096a0d49fdedd0142de4c1765e4b24756c0482cc Mon Sep 17 00:00:00 2001 From: Scott Sanderson Date: Thu, 1 Oct 2015 17:12:48 -0400 Subject: [PATCH] MAINT: Rename drain_pipeline -> pipeline_output. More boring, but *drain* carries a connotation of "get everything", which is misleading. --- tests/pipeline/test_pipeline_algo.py | 24 ++++++++++++------------ zipline/algorithm.py | 12 ++++++------ zipline/errors.py | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/pipeline/test_pipeline_algo.py b/tests/pipeline/test_pipeline_algo.py index b0b25402..7de4b9e7 100644 --- a/tests/pipeline/test_pipeline_algo.py +++ b/tests/pipeline/test_pipeline_algo.py @@ -32,12 +32,12 @@ from testfixtures import TempDirectory from zipline.algorithm import TradingAlgorithm from zipline.api import ( attach_pipeline, - drain_pipeline, + pipeline_output, get_datetime, ) from zipline.errors import ( AttachPipelineAfterInitialize, - DrainPipelineDuringInitialize, + PipelineOutputDuringInitialize, NoSuchPipeline, ) from zipline.finance import trading @@ -206,14 +206,14 @@ class ClosesOnly(TestCase): with self.assertRaises(AttachPipelineAfterInitialize): algo.run(source=self.closes) - def test_drain_pipeline_after_initialize(self): + def test_pipeline_output_after_initialize(self): """ - Assert that calling drain_pipeline after initialize raises correctly. + Assert that calling pipeline_output after initialize raises correctly. """ def initialize(context): attach_pipeline(Pipeline('test')) - drain_pipeline('test') - raise AssertionError("Shouldn't make it past drain_pipeline()") + pipeline_output('test') + raise AssertionError("Shouldn't make it past pipeline_output()") def handle_data(context, data): raise AssertionError("Shouldn't make it past initialize!") @@ -232,10 +232,10 @@ class ClosesOnly(TestCase): env=self.env, ) - with self.assertRaises(DrainPipelineDuringInitialize): + with self.assertRaises(PipelineOutputDuringInitialize): algo.run(source=self.closes) - def test_drain_nonexistent_pipeline(self): + def test_get_output_nonexistent_pipeline(self): """ Assert that calling add_pipeline after initialize raises appropriately. """ @@ -246,8 +246,8 @@ class ClosesOnly(TestCase): raise AssertionError("Shouldn't make it past before_trading_start") def before_trading_start(context, data): - drain_pipeline('not_test') - raise AssertionError("Shouldn't make it past drain_pipeline!") + pipeline_output('not_test') + raise AssertionError("Shouldn't make it past pipeline_output!") algo = TradingAlgorithm( initialize=initialize, @@ -275,7 +275,7 @@ class ClosesOnly(TestCase): attach_pipeline(p) def handle_data(context, data): - results = drain_pipeline('test') + results = pipeline_output('test') date = get_datetime().normalize() for asset in self.assets: # Assets should appear iff they exist today and yesterday. @@ -494,7 +494,7 @@ class PipelineAlgorithmTestCase(TestCase): def handle_data(context, data): today = get_datetime() - results = drain_pipeline('test') + results = pipeline_output('test') expect_over_300 = { AAPL: today < self.AAPL_split_date, MSFT: False, diff --git a/zipline/algorithm.py b/zipline/algorithm.py index c06a4c93..3728874f 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -39,7 +39,7 @@ from zipline.errors import ( OrderDuringInitialize, OverrideCommissionPostInit, OverrideSlippagePostInit, - DrainPipelineDuringInitialize, + PipelineOutputDuringInitialize, RegisterAccountControlPostInit, RegisterTradingControlPostInit, UnsupportedCommissionModel, @@ -1346,8 +1346,8 @@ class TradingAlgorithm(object): self._pipelines.append(pipeline) @api_method - @require_initialized(DrainPipelineDuringInitialize()) - def drain_pipeline(self, name=None): + @require_initialized(PipelineOutputDuringInitialize()) + def pipeline_output(self, name): """ Get the results of pipeline with name `name`. @@ -1382,11 +1382,11 @@ class TradingAlgorithm(object): name=name, valid=[p.name for p in self._pipelines], ) - return self._pipeline_results(p) + return self._pipeline_output(p) - def _pipeline_results(self, pipeline): + def _pipeline_output(self, pipeline): """ - Internal implementation of `drain_pipeline`. + Internal implementation of `pipeline_output`. """ today = normalize_date(self.get_datetime()) try: diff --git a/zipline/errors.py b/zipline/errors.py index 63cf53ac..484dba40 100644 --- a/zipline/errors.py +++ b/zipline/errors.py @@ -387,13 +387,13 @@ class AttachPipelineAfterInitialize(ZiplineError): ) -class DrainPipelineDuringInitialize(ZiplineError): +class PipelineOutputDuringInitialize(ZiplineError): """ - Raised when a user tries to call `drain_pipeline` during initialize. + Raised when a user tries to call `pipeline_output` during initialize. """ msg = ( - "Attempted to call drain_pipeline() during initialize. " - "drain_pipeline() can only be called once initialize has completed." + "Attempted to call pipeline_output() during initialize. " + "pipeline_output() can only be called once initialize has completed." )