def step_function_core(x, step_x=0, flip=False):
    """ Implement a perfect step function f(x) with step at `step_x`:
    
            / 0   if x < step_x
            |
    f(x) = {  0.5 if x = step_x
            |
            \\ 1   if x > step_x

    *Parameters*
    ============================================================================
    x       array; x domain of function
    step_x  float; position of the step
    flip    boolean; Flip the > and < signs in the definition
    ============================================================================
    """
    sign = -1 if flip else 1
    if sign * x < sign * step_x:
        result = 0
    elif x == step_x:
        result = 0.5
    elif sign * x > sign * step_x:
        result = 1
    return result
