code: def test_produce_nans_when_too_much_missing_data(self, nan_offset):
      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
  
      # Write nans in a triangular pattern into the middle of the dependent
      # array.
      nan_grid = np.array(
          [
              [1, 0, 0, 0, 0],
              [1, 1, 0, 0, 0],
              [1, 1, 1, 0, 0],
              [1, 1, 1, 1, 0],
              [1, 1, 1, 1, 1],
          ],
          dtype=bool,
      )
      num_nans = nan_grid.sum(axis=0)
      # Move the grid around in the parameterized tests. The positions
      # shouldn't matter.
      dependents[10 + nan_offset : 15 + nan_offset][nan_grid] = np.nan
  
      for allowed_missing in range(7):
          results = vectorized_beta(
              dependents, independent, allowed_missing
          )
          for i, expected in enumerate(true_betas):
              result = results[i]
              expect_nan = num_nans[i] > allowed_missing
              true_beta = true_betas[i]
              if expect_nan:
                  self.assertTrue(np.isnan(result))
              else:
                  self.assertTrue(np.abs(result - true_beta) < 0.01)
  
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 4 for calling the VectorizedBetaTestCase obj's underlying member method code with example usage: obj.test_produce_nans_when_too_much_missing_data(nan_offset) without return types