def ndarray(typed_array, shape, dtype):
    """Return a ndarray."""
    _dtype = type(typed_array)
    if dtype and dtype != _dtype:
        raise Exception("dtype doesn't match the type of the array: " +
            _dtype + ' != ' + dtype)
    shape = shape or (len(typed_array),)
    return {'__jailed_type__': 'ndarray', '__value__': typed_array,
        '__shape__': shape, '__dtype__': _dtype}
