'Tests for custom factors that compute a 1D out.'

def test_single_column_output(self):

    start_date = self.pipeline_start_date
    end_date = self.pipeline_end_date
    alternating_mask = (AssetIDPlusDay() % 2).eq(0)
    cascading_mask = (AssetIDPlusDay() < (self.sids[(-1)] + start_date.day))
    class SingleColumnOutput(CustomFactor, ):
        window_length = 1
        inputs = [self.col]
        window_safe = True
        ndim = 1
        def compute(self, today, assets, out, col):
            assert (out.shape == (1,))
            assert (col.shape == (1, 3))
            out[:] = col.sum()
    class UsesSingleColumnOutput(CustomFactor, ):
        window_length = 1
        inputs = [SingleColumnOutput()]
        def compute(self, today, assets, out, single_column_output):
            assert (single_column_output.shape == (1, 1))
    for mask in (alternating_mask, cascading_mask):
        columns = {'uses_single_column_output': UsesSingleColumnOutput(), 'uses_single_column_output_masked': UsesSingleColumnOutput(mask=mask)}
        self.run_pipeline(Pipeline(columns=columns), start_date, end_date)
