def as_type(obj, typ):
    # Assume it's a NumPy data type
    try:
        return obj if obj.dtype == typ else obj.astype(typ)
    except AttributeError:
        if isinstance(obj, int):
            return np.int64(obj).astype(typ)
        elif isinstance(obj, float):
            return np.float64(obj).astype(typ)
        else:
            raise TypeError("Invalid type %s" % type(obj))
gnt-node migrate
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/as_type--crossover with--dataset/ETHPy150Open ganeti/ganeti/qa/qa_node.py/TestNodeMigrate