code: def test_allowed_missing_doesnt_double_count(self):
      # Test that allowed_missing only counts a row as missing one
      # observation if it's missing in both the dependent and independent
      # variable.
      rand = np.random.RandomState(42)
      true_betas = np.array([-0.5, 0.0, 0.5, 1.0, 1.5])
      independent = as_column(np.linspace(-5.0, 5.0, 30))
      noise = as_column(rand.uniform(-0.1, 0.1, 30))
      dependents = 1.0 + true_betas * independent + noise
  
      # Each column has three nans in the grid.
      dependent_nan_grid = np.array(
          [
              [0, 1, 1, 1, 0],
              [0, 0, 1, 1, 1],
              [1, 0, 0, 1, 1],
              [1, 1, 0, 0, 1],
              [1, 1, 1, 0, 0],
          ],
          dtype=bool,
      )
      # There are also two nans in the independent data.
      independent_nan_grid = np.array(
          [[0], [0], [1], [1], [0]], dtype=bool
      )
  
      dependents[10:15][dependent_nan_grid] = np.nan
      independent[10:15][independent_nan_grid] = np.nan
  
      # With only two allowed missing values, everything should come up nan,
      # because column has at least 3 nans in the dependent data.
      result2 = vectorized_beta(
          dependents, independent, allowed_missing=2
      )
      assert_equal(
          np.isnan(result2), np.array([True, True, True, True, True])
      )
  
      # With three allowed missing values, the first and last columns should
      # produce a value, because they have nans at the same rows where the
      # independent data has nans.
      result3 = vectorized_beta(
          dependents, independent, allowed_missing=3
      )
      assert_equal(
          np.isnan(result3), np.array([False, True, True, True, False])
      )
  
      # With four allowed missing values, everything but the middle column
      # should produce a value. The middle column will have 5 nans because
      # the dependent nans have no overlap with the independent nans.
      result4 = vectorized_beta(
          dependents, independent, allowed_missing=4
      )
      assert_equal(
          np.isnan(result4),
          np.array([False, False, True, False, False]),
      )
  
      # With five allowed missing values, everything should produce a value.
      result5 = vectorized_beta(
          dependents, independent, allowed_missing=5
      )
      assert_equal(
          np.isnan(result5),
          np.array([False, False, False, False, False]),
      )
  
imports: import numpy
  from numpy import arange, full, full_like, nan, where
  from pandas import DataFrame, date_range, Int64Index, Timestamp
  from pandas.util.testing import assert_frame_equal
  from scipy.stats import linregress, pearsonr, spearmanr
  from empyrical.stats import beta_aligned
  from zipline.assets import Equity, ExchangeInfo
  from zipline.errors import IncompatibleTerms, NonExistentAssetInTimeFrame
  from zipline.pipeline import CustomFactor, Pipeline
  from zipline.pipeline.data import USEquityPricing
  from zipline.pipeline.data.testing import TestingDataSet
  from zipline.pipeline.domain import US_EQUITIES
  from zipline.pipeline.engine import SimplePipelineEngine
  from zipline.pipeline.factors import Returns, RollingLinearRegressionOfReturns, RollingPearsonOfReturns, RollingSpearmanOfReturns, SimpleBeta
  from zipline.pipeline.factors.statistical import vectorized_beta, vectorized_pearson_r
  from zipline.pipeline.loaders.frame import DataFrameLoader
  from zipline.pipeline.sentinels import NotSpecified
  from zipline.testing import AssetID, AssetIDPlusDay, check_arrays, make_alternating_boolean_array, make_cascading_boolean_array, parameter_space
  import zipline.testing.fixtures
  from zipline.testing.predicates import assert_equal
  from zipline.utils.numpy_utils import as_column, bool_dtype, datetime64ns_dtype, float64_dtype
label_desc: Use image node_id 5 for calling the VectorizedBetaTestCase obj's underlying member method code with example usage: obj.test_allowed_missing_doesnt_double_count() without return types