Beispiel #1
0
def arraycast(x, val):
    if type(x) is SparseArray:
        return x
    elif not isinstance(x, anp.ndarray):
        return anp.array(cast(x, val.ravel()[0]))
    else:
        if anp.iscomplexobj(val) and not anp.iscomplexobj(x):
            return anp.array(x, dtype=anp.complex)
        elif not anp.iscomplexobj(val) and anp.iscomplexobj(x):
            return anp.real(anp.array(x))
        else:
            return x
Beispiel #2
0
 def cast(value, example):
     return cast(value, cast_to_list)
Beispiel #3
0
 def cast(value, example):
     return cast(value, cast_to_dict)
Beispiel #4
0
 def cast(value, example):
     return cast(value, cast_to_list)
Beispiel #5
0
 def cast(value, example):
     return cast(value, cast_to_dict)