docstr: Tests for custom factors that compute a 1D out.
docstr_tok: ["Tests","for","custom","factors","that","compute","a","1D","out","."]
code: def test_single_column_output(self):
      """
      Tests for custom factors that compute a 1D out.
      """
      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):
              # Because we specified ndim as 1, `out` should be a singleton
              # array but `close` should be a regular sized input.
              assert out.shape == (1,)
              assert col.shape == (1, 3)
              out[:] = col.sum()
  
      # Since we cannot add single column output factors as pipeline
      # columns, we have to test its output through another factor.
      class UsesSingleColumnOutput(CustomFactor):
          window_length = 1
          inputs = [SingleColumnOutput()]
  
          def compute(self, today, assets, out, single_column_output):
              # Make sure that `single_column` has the correct shape. That
              # is, it should always have one column regardless of any mask
              # passed to `UsesSingleColumnInput`.
              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,
              ),
          }
  
          # Assertions about the expected shapes of our data are made in the
          # `compute` function of our custom factors above.
          self.run_pipeline(
              Pipeline(columns=columns), start_date, end_date
          )
  
imports: from numpy import where
  from pandas import Int64Index, Timestamp
  from pandas.util.testing import assert_frame_equal
  from zipline.assets import Asset, ExchangeInfo
  from zipline.errors import NonExistentAssetInTimeFrame, NonSliceableTerm, NonWindowSafeInput, UnsupportedPipelineOutput
  from zipline.pipeline import CustomFactor, Factor, Filter, Classifier, Pipeline
  from zipline.pipeline.data import USEquityPricing
  from zipline.pipeline.data.testing import TestingDataSet
  from zipline.pipeline.domain import US_EQUITIES
  from zipline.pipeline.factors import Returns, RollingLinearRegressionOfReturns, RollingPearsonOfReturns, RollingSpearmanOfReturns, SimpleMovingAverage
  from zipline.testing import AssetID, AssetIDPlusDay, check_arrays, OpenPrice, parameter_space
  from zipline.testing.fixtures import WithSeededRandomPipelineEngine, ZiplineTestCase
  from zipline.utils.numpy_utils import datetime64ns_dtype
label_desc: Use image node_id 8 for calling the SliceTestCase obj's underlying member method code with example usage: obj.test_single_column_output() without return types