'Test that slices correctly inherit the `window_safe` property of the
term from which they are derived.'

def test_window_safety_of_slices(self):

    col = self.col
    my_asset = self.asset_finder.retrieve_asset(self.sids[0])
    sma = SimpleMovingAverage(inputs=[self.col], window_length=10)
    sma_slice = sma[my_asset]
    class UsesSlicedInput(CustomFactor, ):
        window_length = 1
        inputs = [sma_slice]
        def compute(self, today, assets, out, sma_slice):
            pass
    with self.assertRaises(NonWindowSafeInput):
        self.run_pipeline(Pipeline(columns={'uses_sliced_input': UsesSlicedInput()}), self.pipeline_start_date, self.pipeline_end_date)
    class MyUnsafeFactor(CustomFactor, ):
        window_length = 1
        inputs = [col]
        def compute(self, today, assets, out, col):
            pass
    my_unsafe_factor = MyUnsafeFactor()
    my_unsafe_factor_slice = my_unsafe_factor[my_asset]
    class UsesSlicedInput(CustomFactor, ):
        window_length = 1
        inputs = [my_unsafe_factor_slice]
        def compute(self, today, assets, out, my_unsafe_factor_slice):
            pass
    with self.assertRaises(NonWindowSafeInput):
        self.run_pipeline(Pipeline(columns={'uses_sliced_input': UsesSlicedInput()}), self.pipeline_start_date, self.pipeline_end_date)
    class MySafeFactor(CustomFactor, ):
        window_length = 1
        inputs = [col]
        window_safe = True
        def compute(self, today, assets, out, col):
            pass
    my_safe_factor = MySafeFactor()
    my_safe_factor_slice = my_safe_factor[my_asset]
    with self.assertRaises(NonWindowSafeInput):
        my_unsafe_factor.pearsonr(target=my_safe_factor_slice, correlation_length=10)
    with self.assertRaises(NonWindowSafeInput):
        my_safe_factor.pearsonr(target=my_unsafe_factor_slice, correlation_length=10)
