Example #1
0
def array_from_type(type):
    if type.is_array:
        return type
    elif type.is_tuple or type.is_list:
        dtype = array_from_type(type.base_type)
        if dtype.is_array:
            return dtype.add('ndim', dtype.ndim + 1)
    elif not type.is_object:
        return typesystem.array_(dtype=type, ndim=0)

    return object_
Example #2
0
def promote_to_array(dtype):
    "Promote scalar to 0d array type"
    if not dtype.is_array:
        dtype = typesystem.array_(dtype, 0)
    return dtype