import torch


def heaviside(data):
    """
    A `heaviside step function <https://en.wikipedia.org/wiki/Heaviside_step_function>`_
    that truncates numbers <= 0 to 0 and everything else to 1.
    """
    return torch.where(
        data <= torch.zeros_like(data),
        torch.zeros_like(data),
        torch.ones_like(data),)