def METHOD_NAME(self, datacontainer, replace_with=1.0):
    """Replace nan and inf in datacontainer with a given value.
    Parameters:
    -------------
    datacontainer: DataContainer, BlockDataContainer
    replace_with: float, default 1.0
        Value to replace elements that evaluate to NaN or inf
    In case the input datacontainer is a :code:`BlockDataContainer` the substitution is executed for each container in the :code:`BlockDataContainer`.
    """
    if isinstance(datacontainer, BlockDataContainer):
        for block in datacontainer.containers:
            self.METHOD_NAME(block, replace_with=replace_with)
        return
    tmp = datacontainer.as_array()
    numpy.nan_to_num(tmp, copy=False, nan=replace_with, posinf=replace_with, neginf=replace_with)
    datacontainer.fill(tmp)