def mask(array, predicates, new_value, ty):
    """
    Returns a new array, with each element in the original array satisfying the
    passed-in predicate set to `new_value`

    Args:
        array (WeldObject / Numpy.ndarray): Input array
        predicates (WeldObject / Numpy.ndarray<bool>): Predicate set
        new_value (WeldObject / Numpy.ndarray / str): mask value
        ty (WeldType): Type of each element in the input array

    Returns:
        A WeldObject representing this computation
    """
    weld_obj = WeldObject(encoder_, decoder_)

    array_var = weld_obj.update(array)
    if isinstance(array, WeldObject):
        array_var = array.obj_id
        weld_obj.dependencies[array_var] = array

    predicates_var = weld_obj.update(predicates)
    if isinstance(predicates, WeldObject):
        predicates_var = predicates.obj_id
        weld_obj.dependencies[predicates_var] = predicates

    if str(ty).startswith("vec"):
        new_value_var = weld_obj.update(new_value)
        if isinstance(new_value, WeldObject):
            new_value_var = new_value.obj_id
            weld_obj.dependencies[new_value_var] = new_value
    else:
        new_value_var = "%s(%s)" % (ty, str(new_value))

    weld_template = """
       map(
         zip(%(array)s, %(predicates)s),
         |p: {%(ty)s, bool}| if (p.$1, %(new_value)s, p.$0)
       )
    """
    weld_obj.weld_code = weld_template % {
        "array": array_var,
        "predicates": predicates_var,
        "new_value": new_value_var,
        "ty": ty}

    return weld_obj
def mask ( array , predicates , new_value , ty ) : weld_obj = WeldObject ( encoder_ , decoder_ ) array_var = weld_obj . update ( array ) if isinstance ( array , WeldObject ) : array_var = array . obj_id weld_obj . dependencies [ array_var ] = array predicates_var = weld_obj . update ( predicates ) if isinstance ( predicates , WeldObject ) : predicates_var = predicates . obj_id weld_obj . dependencies [ predicates_var ] = predicates if str ( ty ) . startswith ( "vec" ) : new_value_var = weld_obj . update ( new_value ) if isinstance ( new_value , WeldObject ) : new_value_var = new_value . obj_id weld_obj . dependencies [ new_value_var ] = new_value else : new_value_var = "%s(%s)" % ( ty , str ( new_value ) ) weld_template = """
       map(
         zip(%(array)s, %(predicates)s),
         |p: {%(ty)s, bool}| if (p.$1, %(new_value)s, p.$0)
       )
    """ weld_obj . weld_code = weld_template % { "array" : array_var , "predicates" : predicates_var , "new_value" : new_value_var , "ty" : ty } return weld_obj
Returns a new array, with each element in the original array satisfying the
    passed-in predicate set to `new_value`

    Args:
        array (WeldObject / Numpy.ndarray): Input array
        predicates (WeldObject / Numpy.ndarray<bool>): Predicate set
        new_value (WeldObject / Numpy.ndarray / str): mask value
        ty (WeldType): Type of each element in the input array

    Returns:
        A WeldObject representing this computation