jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def test_transpose():
    x1 = tensor.dvector('x1')
    x2 = tensor.dmatrix('x2')
    x3 = tensor.dtensor3('x3')

    x1v = numpy.arange(24)
    x2v = numpy.arange(24).reshape(2, 12)
    x3v = numpy.arange(24).reshape(2, 3, 4)

    f = theano.function([x1, x2, x3], [
        tensor.transpose(x1),
        tensor.transpose(x2),
        tensor.transpose(x3),
        x1.transpose(),
        x2.transpose(),
        x3.transpose(),
        x2.transpose(0, 1),
        x3.transpose((0, 2, 1)),
        tensor.transpose(x2, [0, 1]),
        tensor.transpose(x3, [0, 2, 1]),
        ])

    t1, t2, t3, t1b, t2b, t3b, t2c, t3c, t2d, t3d = f(x1v, x2v, x3v)
    assert t1.shape == numpy.transpose(x1v).shape
    assert t2.shape == numpy.transpose(x2v).shape
    assert t3.shape == numpy.transpose(x3v).shape
    assert n.all(t1 == numpy.transpose(x1v))
    assert n.all(t2 == numpy.transpose(x2v))
    assert n.all(t3 == numpy.transpose(x3v))
    assert n.all(t1b == x1v.transpose())
    assert n.all(t2b == x2v.transpose())
    assert n.all(t3b == x3v.transpose())
    assert t2c.shape == (2, 12)
    assert t3c.shape == (2, 4, 3)
    assert n.all(t2c == x2v.transpose([0, 1]))
    assert n.all(t3c == x3v.transpose([0, 2, 1]))
    assert t2d.shape == (2, 12)
    assert t3d.shape == (2, 4, 3)
    assert n.all(t2d == numpy.transpose(x2v, [0, 1]))
    assert n.all(t3d == numpy.transpose(x3v, [0, 2, 1]))

    # Check that we create a name.
    assert tensor.transpose(x1).name == 'x1.T'
    assert tensor.transpose(x2).name == 'x2.T'
    assert tensor.transpose(x3).name == 'x3.T'
    assert tensor.transpose(tensor.dmatrix()).name is None
//  [python]
def test_transpose():
    x1 = tensor.dvector('x1')
    x2 = tensor.dmatrix('x2')
    x3 = tensor.dtensor3('x3')

    x1v = numpy.arange(24)
    x2v = numpy.arange(24).reshape(2, 12)
    x3v = numpy.arange(24).reshape(2, 3, 4)

    f = theano.function([x1, x2, x3], [
        tensor.transpose(x1),
        tensor.transpose(x2),
        tensor.transpose(x3),
        x1.transpose(),
        x2.transpose(),
        x3.transpose(),
        x2.transpose(0, 1),
        x3.transpose((0, 2, 1)),
        tensor.transpose(x2, [0, 1]),
        tensor.transpose(x3, [0, 2, 1]),
        ])

    t1, t2, t3, t1b, t2b, t3b, t2c, t3c, t2d, t3d = f(x1v, x2v, x3v)
    assert t1.shape == numpy.transpose(x1v).shape
    assert t2.shape == numpy.transpose(x2v).shape
    assert t3.shape == numpy.transpose(x3v).shape
    assert numpy.all(t1 == numpy.transpose(x1v))
    assert numpy.all(t2 == numpy.transpose(x2v))
    assert numpy.all(t3 == numpy.transpose(x3v))
    assert numpy.all(t1b == x1v.transpose())
    assert numpy.all(t2b == x2v.transpose())
    assert numpy.all(t3b == x3v.transpose())
    assert t2c.shape == (2, 12)
    assert t3c.shape == (2, 4, 3)
    assert numpy.all(t2c == x2v.transpose([0, 1]))
    assert numpy.all(t3c == x3v.transpose([0, 2, 1]))
    assert t2d.shape == (2, 12)
    assert t3d.shape == (2, 4, 3)
    assert numpy.all(t2d == numpy.transpose(x2v, [0, 1]))
    assert numpy.all(t3d == numpy.transpose(x3v, [0, 2, 1]))

    # Check that we create a name.
    assert tensor.transpose(x1).name == 'x1.T'
    assert tensor.transpose(x2).name == 'x2.T'
    assert tensor.transpose(x3).name == 'x3.T'
    assert tensor.transpose(tensor.dmatrix()).name is None
//  [python]
def _check_range(self, x, cmin, cmax):
        assert_(n.all(x >= cmin))
        assert_(n.all(x <= cmax))
//  [python]
def _check_range(self, x, cmin, cmax):
        assert_(np.all(x >= cmin))
        assert_(np.all(x <= cmax))
//  [python]
def test_all(self, method):
        a = np.random.normal(0, 1, (4, 5, 6, 7, 8))
        arg_method = getattr(a, 'arg' + method)
        val_method = getattr(a, method)
        for i in range(a.ndim):
            a_maxmin = val_method(i)
            aarg_maxmin = arg_method(i)
            axes = list(range(a.ndim))
            axes.remove(i)
            assert_(np.all(a_maxmin == aarg_maxmin.choose(
                                        *a.transpose(i, *axes))))
//  [python]
def test_all_where(self):
        a = np.array([[True, False, True],
                      [False, False, False],
                      [True, True, True]])
        wh_full = np.array([[True, False, True],
                            [False, False, False],
                            [True, False, True]])
        wh_lower = np.array([[False],
                             [False],
                             [True]])
        for _ax in [0, None]:
            assert_equal(np.all(a, axis=_ax, where=wh_lower),
                        np.all(a[wh_lower[:,0],:], axis=_ax))
            assert_equal(np.all(a, axis=_ax, where=wh_lower),
                         a[wh_lower[:,0],:].all(axis=_ax))

        assert_equal(np.all(a, where=wh_full), True)
        assert_equal(np.all(a, where=wh_full), True)
        assert_equal(np.all(a, where=False), True)
        assert_equal(np.all(a, where=False), True)
//  [python]
def test_all_where(self):
        a = np.array([[True, False, True],
                      [False, False, False],
                      [True, True, True]])
        wh_full = np.array([[True, False, True],
                            [False, False, False],
                            [True, False, True]])
        wh_lower = np.array([[False],
                             [False],
                             [True]])
        for _ax in [0, None]:
            assert_equal(a.all(axis=_ax, where=wh_lower),
                        np.all(a[wh_lower[:,0],:], axis=_ax))
            assert_equal(np.all(a, axis=_ax, where=wh_lower),
                         a[wh_lower[:,0],:].all(axis=_ax))

        assert_equal(a.all(where=wh_full), True)
        assert_equal(np.all(a, where=wh_full), True)
        assert_equal(a.all(where=False), True)
        assert_equal(np.all(a, where=False), True)
//  [python]
def test_max_or_min(self):
        val = np.array([0, 1, 2, 3, 4, 5, 6, 7])
        x = val.clip(3)
        assert_(x.all() >= 3)
        x = val.clip(min=3)
        assert_(x.all() >= 3)
        x = val.clip(max=4)
        assert_(x.all() <= 4)
//  [python]
def test_max_or_min(self):
        val = np.array([0, 1, 2, 3, 4, 5, 6, 7])
        x = val.clip(3)
        assert_(np.all(x >= 3))
        x = val.clip(min=3)
        assert_(np.all(x >= 3))
        x = val.clip(max=4)
        assert_(np.all(x <= 4))
//  [python]
def _get_recordmask(self):
        """
        Return the mask of the records.

        A record is masked when all the fields are masked.

        """
        _mask = self._mask.view(ndarray)
        if _mask.dtype.names is None:
            return _mask
        return np.alltrue(flatten_structured_array(_mask), axis=-1)
//  [python]
def _get_recordmask(self):
        """
        Return the mask of the records.

        A record is masked when all the fields are masked.

        """
        _mask = self._mask.view(ndarray)
        if _mask.dtype.names is None:
            return _mask
        return np.all(flatten_structured_array(_mask), axis=-1)
//  [python]
def coerce_to_array(
    values, mask=None, copy: bool = False
) -> tuple[np.ndarray, np.ndarray]:
    """
    Coerce the input values array to numpy arrays with a mask.

    Parameters
    ----------
    values : 1D list-like
    mask : bool 1D array, optional
    copy : bool, default False
        if True, copy the input

    Returns
    -------
    tuple of (values, mask)
    """
    if isinstance(values, BooleanArray):
        if mask is not None:
            raise ValueError("cannot pass mask for BooleanArray input")
        values, mask = values._data, values._mask
        if copy:
            values = values.copy()
            mask = mask.copy()
        return values, mask

    mask_values = None
    if isinstance(values, np.ndarray) and values.dtype == np.bool_:
        if copy:
            values = values.copy()
    elif isinstance(values, np.ndarray) and is_numeric_dtype(values.dtype):
        mask_values = isna(values)

        values_bool = np.zeros(len(values), dtype=bool)
        values_bool[~mask_values] = values[~mask_values].astype(bool)

        if not n.all(
            values_bool[~mask_values].astype(values.dtype) == values[~mask_values]
        ):
            raise TypeError("Need to pass bool-like values")

        values = values_bool
    else:
        values_object = np.asarray(values, dtype=object)

        inferred_dtype = lib.infer_dtype(values_object, skipna=True)
        integer_like = ("floating", "integer", "mixed-integer-float")
        if inferred_dtype not in ("boolean", "empty") + integer_like:
            raise TypeError("Need to pass bool-like values")

        # mypy does not narrow the type of mask_values to npt.NDArray[np.bool_]
        # within this branch, it assumes it can also be None
        mask_values = cast("npt.NDArray[np.bool_]", isna(values_object))
        values = np.zeros(len(values), dtype=bool)
        values[~mask_values] = values_object[~mask_values].astype(bool)

        # if the values were integer-like, validate it were actually 0/1's
        if (inferred_dtype in integer_like) and not (
            n.all(
                values[~mask_values].astype(float)
                == values_object[~mask_values].astype(float)
            )
        ):
            raise TypeError("Need to pass bool-like values")

    if mask is None and mask_values is None:
        mask = np.zeros(values.shape, dtype=bool)
    elif mask is None:
        mask = mask_values
    else:
        if isinstance(mask, np.ndarray) and mask.dtype == np.bool_:
            if mask_values is not None:
                mask = mask | mask_values
            else:
                if copy:
                    mask = mask.copy()
        else:
            mask = np.array(mask, dtype=bool)
            if mask_values is not None:
                mask = mask | mask_values

    if values.shape != mask.shape:
        raise ValueError("values.shape and mask.shape must match")

    return values, mask
//  [python]
def coerce_to_array(
    values, mask=None, copy: bool = False
) -> tuple[np.ndarray, np.ndarray]:
    """
    Coerce the input values array to numpy arrays with a mask.

    Parameters
    ----------
    values : 1D list-like
    mask : bool 1D array, optional
    copy : bool, default False
        if True, copy the input

    Returns
    -------
    tuple of (values, mask)
    """
    if isinstance(values, BooleanArray):
        if mask is not None:
            raise ValueError("cannot pass mask for BooleanArray input")
        values, mask = values._data, values._mask
        if copy:
            values = values.copy()
            mask = mask.copy()
        return values, mask

    mask_values = None
    if isinstance(values, np.ndarray) and values.dtype == np.bool_:
        if copy:
            values = values.copy()
    elif isinstance(values, np.ndarray) and is_numeric_dtype(values.dtype):
        mask_values = isna(values)

        values_bool = np.zeros(len(values), dtype=bool)
        values_bool[~mask_values] = values[~mask_values].astype(bool)

        if not np.all(
            values_bool[~mask_values].astype(values.dtype) == values[~mask_values]
        ):
            raise TypeError("Need to pass bool-like values")

        values = values_bool
    else:
        values_object = np.asarray(values, dtype=object)

        inferred_dtype = lib.infer_dtype(values_object, skipna=True)
        integer_like = ("floating", "integer", "mixed-integer-float")
        if inferred_dtype not in ("boolean", "empty") + integer_like:
            raise TypeError("Need to pass bool-like values")

        # mypy does not narrow the type of mask_values to npt.NDArray[np.bool_]
        # within this branch, it assumes it can also be None
        mask_values = cast("npt.NDArray[np.bool_]", isna(values_object))
        values = np.zeros(len(values), dtype=bool)
        values[~mask_values] = values_object[~mask_values].astype(bool)

        # if the values were integer-like, validate it were actually 0/1's
        if (inferred_dtype in integer_like) and not (
            np.all(
                values[~mask_values].astype(float)
                == values_object[~mask_values].astype(float)
            )
        ):
            raise TypeError("Need to pass bool-like values")

    if mask is None and mask_values is None:
        mask = np.zeros(values.shape, dtype=bool)
    elif mask is None:
        mask = mask_values
    else:
        if isinstance(mask, np.ndarray) and mask.dtype == np.bool_:
            if mask_values is not None:
                mask = mask | mask_values
            else:
                if copy:
                    mask = mask.copy()
        else:
            mask = np.array(mask, dtype=bool)
            if mask_values is not None:
                mask = mask | mask_values

    if values.shape != mask.shape:
        raise ValueError("values.shape and mask.shape must match")

    return values, mask
//  [python]
def test_results(self):
        a = np.arange(1*2*3*4).reshape(1, 2, 3, 4).copy()
        aind = np.indices(a.shape)
        assert_(a.flags['OWNDATA'])
        for (i, j) in self.tgtshape:
            # positive axis, positive start
            res = np.rollaxis(a, axis=i, start=j)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(n.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(i, j)], str((i,j)))
            assert_(not res.flags['OWNDATA'])

            # negative axis, positive start
            ip = i + 1
            res = np.rollaxis(a, axis=-ip, start=j)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(n.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(4 - ip, j)])
            assert_(not res.flags['OWNDATA'])

            # positive axis, negative start
            jp = j + 1 if j < 4 else j
            res = np.rollaxis(a, axis=i, start=-jp)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(n.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(i, 4 - jp)])
            assert_(not res.flags['OWNDATA'])

            # negative axis, negative start
            ip = i + 1
            jp = j + 1 if j < 4 else j
            res = np.rollaxis(a, axis=-ip, start=-jp)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(n.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(4 - ip, 4 - jp)])
            assert_(not res.flags['OWNDATA'])
//  [python]
def test_results(self):
        a = np.arange(1*2*3*4).reshape(1, 2, 3, 4).copy()
        aind = np.indices(a.shape)
        assert_(a.flags['OWNDATA'])
        for (i, j) in self.tgtshape:
            # positive axis, positive start
            res = np.rollaxis(a, axis=i, start=j)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(np.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(i, j)], str((i,j)))
            assert_(not res.flags['OWNDATA'])

            # negative axis, positive start
            ip = i + 1
            res = np.rollaxis(a, axis=-ip, start=j)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(np.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(4 - ip, j)])
            assert_(not res.flags['OWNDATA'])

            # positive axis, negative start
            jp = j + 1 if j < 4 else j
            res = np.rollaxis(a, axis=i, start=-jp)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(np.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(i, 4 - jp)])
            assert_(not res.flags['OWNDATA'])

            # negative axis, negative start
            ip = i + 1
            jp = j + 1 if j < 4 else j
            res = np.rollaxis(a, axis=-ip, start=-jp)
            i0, i1, i2, i3 = aind[np.array(res.shape) - 1]
            assert_(np.all(res[i0, i1, i2, i3] == a))
            assert_(res.shape == self.tgtshape[(4 - ip, 4 - jp)])
            assert_(not res.flags['OWNDATA'])
//  [python]
def __eq__(self, other):
        """
        Check whether other equals self elementwise.

        """
        if self is masked:
            return masked
        omask = getattr(other, '_mask', nomask)
        if omask is nomask:
            check = self.filled(0).__eq__(other)
            try:
                check = check.view(type(self))
                check._mask = self._mask
            except AttributeError:
                # Dang, we have a bool instead of an array: return the bool
                return check
        else:
            odata = filled(other, 0)
            check = self.filled(0).__eq__(odata).view(type(self))
            if self._mask is nomask:
                check._mask = omask
            else:
                mask = mask_or(self._mask, omask)
                if mask.dtype.names:
                    if mask.size > 1:
                        axis = 1
                    else:
                        axis = None
                    try:
                        mask = mask.view((bool_, len(self.dtype))).all(axis)
                    except ValueError:
                        mask = n.all([[f[n].all() for n in mask.dtype.names]
                                       for f in mask], axis=axis)
                check._mask = mask
        return check
//  [python]
def __eq__(self, other):
        """
        Check whether other equals self elementwise.

        """
        if self is masked:
            return masked
        omask = getattr(other, '_mask', nomask)
        if omask is nomask:
            check = self.filled(0).__eq__(other)
            try:
                check = check.view(type(self))
                check._mask = self._mask
            except AttributeError:
                # Dang, we have a bool instead of an array: return the bool
                return check
        else:
            odata = filled(other, 0)
            check = self.filled(0).__eq__(odata).view(type(self))
            if self._mask is nomask:
                check._mask = omask
            else:
                mask = mask_or(self._mask, omask)
                if mask.dtype.names:
                    if mask.size > 1:
                        axis = 1
                    else:
                        axis = None
                    try:
                        mask = mask.view((bool_, len(self.dtype))).all(axis)
                    except ValueError:
                        mask = np.all([[f[n].all() for n in mask.dtype.names]
                                       for f in mask], axis=axis)
                check._mask = mask
        return check
//  [python]
def modMaps(tauMap, T_map, Q_map, U_map, isOpticalDepth = True):

    if not(n.all(n.isreal(tauMap))):
        raise ValueError('input mod map should be real.')

    Tloc = T_map.copy()
    Qloc = Q_map.copy()
    Uloc = U_map.copy()

    modFac = (n.exp(-1 * tauMap.data) if isOpticalDepth else modFac)


    Tloc.data = modFac * Tloc.data
    Qloc.data = modFac * Qloc.data
    Uloc.data = modFac * Uloc.data

    
    return (Tloc, Qloc, Uloc)
//  [python]
def modMaps(tauMap, T_map, Q_map, U_map, isOpticalDepth = True):

    if not(numpy.all(numpy.isreal(tauMap))):
        raise ValueError('input mod map should be real.')

    Tloc = T_map.copy()
    Qloc = Q_map.copy()
    Uloc = U_map.copy()

    modFac = (numpy.exp(-1 * tauMap.data) if isOpticalDepth else modFac)


    Tloc.data = modFac * Tloc.data
    Qloc.data = modFac * Qloc.data
    Uloc.data = modFac * Uloc.data

    
    return (Tloc, Qloc, Uloc)
//  [python]
def rotMaps(alphaMapRad, T_map, Q_map, U_map):
#note T map is unaffected
    

    if not(numpy.alltrue(numpy.isreal(alphaMapRad))):
        raise ValueError('input rotation map should be real.')

    Qloc = Q_map.copy()
    Uloc = U_map.copy()



    plus = Qloc.data + 1j * Uloc.data

    minus = Qloc.data - 1j * Uloc.data


    plusRot =   numpy.exp(+2 * 1j * alphaMapRad.data) * plus
    minusRot =  numpy.exp(-2 * 1j * alphaMapRad.data) * minus


    #note, result should be real regardless (if the initial Q/U is, that is) --
    #we just don't want an imaginary part to be stored.
    Qloc.data = numpy.real(1./2.        * (plusRot + minusRot))
    Uloc.data = numpy.real(1./(2. * 1j) * (plusRot - minusRot))


    
    return (T_map.copy(), Qloc, Uloc)
//  [python]
def rotMaps(alphaMapRad, T_map, Q_map, U_map):
#note T map is unaffected
    

    if not(numpy.all(numpy.isreal(alphaMapRad))):
        raise ValueError('input rotation map should be real.')

    Qloc = Q_map.copy()
    Uloc = U_map.copy()



    plus = Qloc.data + 1j * Uloc.data

    minus = Qloc.data - 1j * Uloc.data


    plusRot =   numpy.exp(+2 * 1j * alphaMapRad.data) * plus
    minusRot =  numpy.exp(-2 * 1j * alphaMapRad.data) * minus


    #note, result should be real regardless (if the initial Q/U is, that is) --
    #we just don't want an imaginary part to be stored.
    Qloc.data = numpy.real(1./2.        * (plusRot + minusRot))
    Uloc.data = numpy.real(1./(2. * 1j) * (plusRot - minusRot))


    
    return (T_map.copy(), Qloc, Uloc)
//  [python]
def __ne__(self, other):
        """
        Check whether other doesn't equal self elementwise

        """
        if self is masked:
            return masked
        omask = getattr(other, '_mask', nomask)
        if omask is nomask:
            check = self.filled(0).__ne__(other)
            try:
                check = check.view(type(self))
                check._mask = self._mask
            except AttributeError:
                # In case check is a boolean (or a numpy.bool)
                return check
        else:
            odata = filled(other, 0)
            check = self.filled(0).__ne__(odata).view(type(self))
            if self._mask is nomask:
                check._mask = omask
            else:
                mask = mask_or(self._mask, omask)
                if mask.dtype.names:
                    if mask.size > 1:
                        axis = 1
                    else:
                        axis = None
                    try:
                        mask = mask.view((bool_, len(self.dtype))).all(axis)
                    except ValueError:
                        mask = n.all([[f[n].all() for n in mask.dtype.names]
                                       for f in mask], axis=axis)
                check._mask = mask
        return check
//  [python]
def __ne__(self, other):
        """
        Check whether other doesn't equal self elementwise

        """
        if self is masked:
            return masked
        omask = getattr(other, '_mask', nomask)
        if omask is nomask:
            check = self.filled(0).__ne__(other)
            try:
                check = check.view(type(self))
                check._mask = self._mask
            except AttributeError:
                # In case check is a boolean (or a numpy.bool)
                return check
        else:
            odata = filled(other, 0)
            check = self.filled(0).__ne__(odata).view(type(self))
            if self._mask is nomask:
                check._mask = omask
            else:
                mask = mask_or(self._mask, omask)
                if mask.dtype.names:
                    if mask.size > 1:
                        axis = 1
                    else:
                        axis = None
                    try:
                        mask = mask.view((bool_, len(self.dtype))).all(axis)
                    except ValueError:
                        mask = np.all([[f[n].all() for n in mask.dtype.names]
                                       for f in mask], axis=axis)
                check._mask = mask
        return check
//  [python]
def test_rvs(self):
        vals = stats.binom.rvs(10, 0.75, size=(2, 50))
        assert_(n.all(vals >= 0) & n.all(vals <= 10))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.binom.rvs(10, 0.75)
        assert_(isinstance(val, int))
        val = stats.binom(10, 0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.binom.rvs(10, 0.75, size=(2, 50))
        assert_(numpy.all(vals >= 0) & numpy.all(vals <= 10))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.binom.rvs(10, 0.75)
        assert_(isinstance(val, int))
        val = stats.binom(10, 0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def psf2otf(psf, shape=None):
    """
    Convert point-spread function to optical transfer function.
    Compute the Fast Fourier Transform (FFT) of the point-spread
    function (PSF) array and creates the optical transfer function (OTF)
    array that is not influenced by the PSF off-centering.
    By default, the OTF array is the same size as the PSF array.
    To ensure that the OTF is not altered due to PSF off-centering, PSF2OTF
    post-pads the PSF array (down or to the right) with zeros to match
    dimensions specified in OUTSIZE, then circularly shifts the values of
    the PSF array up (or to the left) until the central pixel reaches (1,1)
    position.
    Parameters
    ----------
    psf : `numpy.ndarray`
        PSF array
    shape : int
        Output shape of the OTF array
    Returns
    -------
    otf : `numpy.ndarray`
        OTF array
    Notes
    -----
    Adapted from MATLAB psf2otf function
    """
    if type(shape) == type(None):
        shape = psf.shape
    shape = np.array(shape)
    if np.all(psf == 0):
        # return np.zeros_like(psf)
        return np.zeros(shape)
    if len(psf.shape) == 1:
        psf = psf.reshape((1, psf.shape[0]))
    inshape = psf.shape
    psf = zero_pad(psf, shape, position='corner')
    for axis, axis_size in enumerate(inshape):
        psf = np.roll(psf, -int(axis_size / 2), axis=axis)
    # Compute the OTF
    otf = np.fft.fft2(psf, axes=(0, 1))
    # Estimate the rough number of operations involved in the FFT
    # and discard the PSF imaginary part if within roundoff error
    # roundoff error  = machine epsilon = sys.float_info.epsilon
    # or np.finfo().eps
    n_ops = np.sum(psf.size * np.log2(psf.shape))
    otf = np.real_if_close(otf, tol=n_ops)
    return otf
//  [python]
def test_eq_index(self):
        section_size = 4
        section_count = 16
        partial = UnboundedPartial3DArray(
            numpy.uint32,
            0,
            (section_size, section_size, section_size),
            (0, section_count),
        )
        bounded_partial = partial[:, :, :]
        self.assertTrue(n.all(bounded_partial == 0))

        arange = numpy.arange(section_size**3 * section_count).reshape(
            (section_size, section_size * section_count, section_size)
        )
        partial[:, :, :] = arange

        self.assertTrue(n.all(bounded_partial == arange))

        bounded_partial[numpy.asarray(bounded_partial) % 2 == 1] = 10
        arange[arange % 2 == 1] = 10

        self.assertTrue(n.all(bounded_partial == arange))
//  [python]
def test_eq_index(self):
        section_size = 4
        section_count = 16
        partial = UnboundedPartial3DArray(
            numpy.uint32,
            0,
            (section_size, section_size, section_size),
            (0, section_count),
        )
        bounded_partial = partial[:, :, :]
        self.assertTrue(numpy.all(bounded_partial == 0))

        arange = numpy.arange(section_size**3 * section_count).reshape(
            (section_size, section_size * section_count, section_size)
        )
        partial[:, :, :] = arange

        self.assertTrue(numpy.all(bounded_partial == arange))

        bounded_partial[numpy.asarray(bounded_partial) % 2 == 1] = 10
        arange[arange % 2 == 1] = 10

        self.assertTrue(numpy.all(bounded_partial == arange))
//  [python]
def test_rvs(self):
        vals = stats.randint.rvs(5,30,size=100)
        assert_(n.all(vals < 30) & n.all(vals >= 5))
        assert_(len(vals) == 100)
        vals = stats.randint.rvs(5,30,size=(2,50))
        assert_(numpy.shape(vals) == (2,50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.randint.rvs(15,46)
        assert_((val >= 15) & (val < 46))
        assert_(isinstance(val, numpy.ScalarType), msg=repr(type(val)))
        val = stats.randint(15,46).rvs(3)
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.randint.rvs(5,30,size=100)
        assert_(numpy.all(vals < 30) & numpy.all(vals >= 5))
        assert_(len(vals) == 100)
        vals = stats.randint.rvs(5,30,size=(2,50))
        assert_(numpy.shape(vals) == (2,50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.randint.rvs(15,46)
        assert_((val >= 15) & (val < 46))
        assert_(isinstance(val, numpy.ScalarType), msg=repr(type(val)))
        val = stats.randint(15,46).rvs(3)
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.bernoulli.rvs(0.75, size=(2, 50))
        assert_(n.all(vals >= 0) & n.all(vals <= 1))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.bernoulli.rvs(0.75)
        assert_(isinstance(val, int))
        val = stats.bernoulli(0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.bernoulli.rvs(0.75, size=(2, 50))
        assert_(numpy.all(vals >= 0) & numpy.all(vals <= 1))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.bernoulli.rvs(0.75)
        assert_(isinstance(val, int))
        val = stats.bernoulli(0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.nbinom.rvs(10, 0.75, size=(2, 50))
        assert_(n.all(vals >= 0))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.nbinom.rvs(10, 0.75)
        assert_(isinstance(val, int))
        val = stats.nbinom(10, 0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.nbinom.rvs(10, 0.75, size=(2, 50))
        assert_(numpy.all(vals >= 0))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.nbinom.rvs(10, 0.75)
        assert_(isinstance(val, int))
        val = stats.nbinom(10, 0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_set(self):
        section_size = 4
        section_count = 16
        partial = UnboundedPartial3DArray(
            numpy.uint32,
            0,
            (section_size, section_size, section_size),
            (0, section_count),
        )

        partial[:, :4, :] = 5
        self.assertTrue(n.all(n.asarray(partial[:, :4, :]) == 5))
        self.assertEqual(tuple(partial.sections), (0,))
        self.assertTrue(n.all(partial.get_section(0) == 5))
        partial[:, 2:6, :] = 10
        self.assertTrue(n.all(n.asarray(partial[:, :2, :]) == 5))
        self.assertTrue(n.all(n.asarray(partial[:, 2:6, :]) == 10))
        self.assertTrue(n.all(n.asarray(partial[:, 6:, :]) == 0))

        self.assertEqual(tuple(partial.sections), (0, 1))

        arange = numpy.arange(section_size**3 * 4).reshape(
            (section_size, section_size * 4, section_size)
        )
        partial[:, int(section_size * 4.5) : int(section_size * 8.5), :] = arange
        self.assertTrue(
            n.array_equal(
                partial[:, int(section_size * 4.5) : int(section_size * 8.5), :], arange
            )
        )

        partial[:, int(section_size * 8.5) : int(section_size * 12.5), :] = partial[
            :, int(section_size * 4.5) : int(section_size * 8.5), :
        ]
        self.assertTrue(
            n.array_equal(
                partial[:, int(section_size * 8.5) : int(section_size * 12.5), :],
                arange,
            )
        )
        self.assertTrue(
            n.array_equal(
                partial[:, int(section_size * 4.5) : int(section_size * 8.5), :],
                partial[:, int(section_size * 8.5) : int(section_size * 12.5), :],
            )
        )
//  [python]
def test_set(self):
        section_size = 4
        section_count = 16
        partial = UnboundedPartial3DArray(
            numpy.uint32,
            0,
            (section_size, section_size, section_size),
            (0, section_count),
        )

        partial[:, :4, :] = 5
        self.assertTrue(numpy.all(numpy.asarray(partial[:, :4, :]) == 5))
        self.assertEqual(tuple(partial.sections), (0,))
        self.assertTrue(numpy.all(partial.get_section(0) == 5))
        partial[:, 2:6, :] = 10
        self.assertTrue(numpy.all(numpy.asarray(partial[:, :2, :]) == 5))
        self.assertTrue(numpy.all(numpy.asarray(partial[:, 2:6, :]) == 10))
        self.assertTrue(numpy.all(numpy.asarray(partial[:, 6:, :]) == 0))

        self.assertEqual(tuple(partial.sections), (0, 1))

        arange = numpy.arange(section_size**3 * 4).reshape(
            (section_size, section_size * 4, section_size)
        )
        partial[:, int(section_size * 4.5) : int(section_size * 8.5), :] = arange
        self.assertTrue(
            numpy.array_equal(
                partial[:, int(section_size * 4.5) : int(section_size * 8.5), :], arange
            )
        )

        partial[:, int(section_size * 8.5) : int(section_size * 12.5), :] = partial[
            :, int(section_size * 4.5) : int(section_size * 8.5), :
        ]
        self.assertTrue(
            numpy.array_equal(
                partial[:, int(section_size * 8.5) : int(section_size * 12.5), :],
                arange,
            )
        )
        self.assertTrue(
            numpy.array_equal(
                partial[:, int(section_size * 4.5) : int(section_size * 8.5), :],
                partial[:, int(section_size * 8.5) : int(section_size * 12.5), :],
            )
        )
//  [python]
def test_eq(self):
        section_size = 4
        section_count = 16
        partial = UnboundedPartial3DArray(
            numpy.uint32,
            0,
            (section_size, section_size, section_size),
            (0, section_count),
        )
        bounded_partial = partial[:, :, :]
        self.assertTrue(n.all(bounded_partial == 0))
        self.assertTrue(n.all(0 == bounded_partial))
        self.assertFalse(n.all(bounded_partial == 10))
        self.assertFalse(n.all(10 == bounded_partial))
        self.assertFalse(n.any(bounded_partial == 10))
        self.assertFalse(n.any(10 == bounded_partial))

        arange = numpy.arange(section_size**3 * 4).reshape(
            (section_size, section_size * 4, section_size)
        )
        partial[:, int(section_size * 4.5) : int(section_size * 8.5), :] = arange

        self.assertTrue(
            n.all(
                arange
                == partial[:, int(section_size * 4.5) : int(section_size * 8.5), :]
            )
        )
        self.assertTrue(
            n.all(
                partial[:, int(section_size * 4.5) : int(section_size * 8.5), :]
                == arange
            )
        )

        self.assertFalse(
            n.all(
                arange
                == partial[:, int(section_size * 8.5) : int(section_size * 12.5), :]
            )
        )
        self.assertFalse(
            n.all(
                numpy.zeros((section_size, section_size * 4, section_size))
                == partial[:, int(section_size * 4.5) : int(section_size * 8.5), :]
            )
        )
        self.assertTrue(
            n.all(
                numpy.zeros((section_size, section_size * 4, section_size))
                == partial[:, int(section_size * 8.5) : int(section_size * 12.5), :]
            )
        )
//  [python]
def test_eq(self):
        section_size = 4
        section_count = 16
        partial = UnboundedPartial3DArray(
            numpy.uint32,
            0,
            (section_size, section_size, section_size),
            (0, section_count),
        )
        bounded_partial = partial[:, :, :]
        self.assertTrue(numpy.all(bounded_partial == 0))
        self.assertTrue(numpy.all(0 == bounded_partial))
        self.assertFalse(numpy.all(bounded_partial == 10))
        self.assertFalse(numpy.all(10 == bounded_partial))
        self.assertFalse(numpy.any(bounded_partial == 10))
        self.assertFalse(numpy.any(10 == bounded_partial))

        arange = numpy.arange(section_size**3 * 4).reshape(
            (section_size, section_size * 4, section_size)
        )
        partial[:, int(section_size * 4.5) : int(section_size * 8.5), :] = arange

        self.assertTrue(
            numpy.all(
                arange
                == partial[:, int(section_size * 4.5) : int(section_size * 8.5), :]
            )
        )
        self.assertTrue(
            numpy.all(
                partial[:, int(section_size * 4.5) : int(section_size * 8.5), :]
                == arange
            )
        )

        self.assertFalse(
            numpy.all(
                arange
                == partial[:, int(section_size * 8.5) : int(section_size * 12.5), :]
            )
        )
        self.assertFalse(
            numpy.all(
                numpy.zeros((section_size, section_size * 4, section_size))
                == partial[:, int(section_size * 4.5) : int(section_size * 8.5), :]
            )
        )
        self.assertTrue(
            numpy.all(
                numpy.zeros((section_size, section_size * 4, section_size))
                == partial[:, int(section_size * 8.5) : int(section_size * 12.5), :]
            )
        )
//  [python]
def test_cdf_bounds(self):
        # CDF should always be positive
        cdf = stats.genexpon.cdf(numpy.arange(0, 10, 0.01), 0.5, 0.5, 2.0)
        assert_(n.all((0 <= cdf) & (cdf <= 1)))
//  [python]
def test_cdf_bounds(self):
        # CDF should always be positive
        cdf = stats.genexpon.cdf(numpy.arange(0, 10, 0.01), 0.5, 0.5, 2.0)
        assert_(numpy.all((0 <= cdf) & (cdf <= 1)))
//  [python]
def test_rvs(self):
        vals = stats.geom.rvs(0.75, size=(2, 50))
        assert_(n.all(vals >= 0))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.geom.rvs(0.75)
        assert_(isinstance(val, int))
        val = stats.geom(0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.geom.rvs(0.75, size=(2, 50))
        assert_(numpy.all(vals >= 0))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.geom.rvs(0.75)
        assert_(isinstance(val, int))
        val = stats.geom(0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.logser.rvs(0.75, size=(2, 50))
        assert_(n.all(vals >= 1))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.logser.rvs(0.75)
        assert_(isinstance(val, int))
        val = stats.logser(0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.logser.rvs(0.75, size=(2, 50))
        assert_(numpy.all(vals >= 1))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.logser.rvs(0.75)
        assert_(isinstance(val, int))
        val = stats.logser(0.75).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.poisson.rvs(0.5, size=(2, 50))
        assert_(n.all(vals >= 0))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.poisson.rvs(0.5)
        assert_(isinstance(val, int))
        val = stats.poisson(0.5).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.poisson.rvs(0.5, size=(2, 50))
        assert_(numpy.all(vals >= 0))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.poisson.rvs(0.5)
        assert_(isinstance(val, int))
        val = stats.poisson(0.5).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.hypergeom.rvs(20, 10, 3, size=(2, 50))
        assert_(n.all(vals >= 0) &
               n.all(vals <= 3))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.hypergeom.rvs(20, 3, 10)
        assert_(isinstance(val, int))
        val = stats.hypergeom(20, 3, 10).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.hypergeom.rvs(20, 10, 3, size=(2, 50))
        assert_(numpy.all(vals >= 0) &
               numpy.all(vals <= 3))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.hypergeom.rvs(20, 3, 10)
        assert_(isinstance(val, int))
        val = stats.hypergeom(20, 3, 10).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.zipf.rvs(1.5, size=(2, 50))
        assert_(n.all(vals >= 1))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.zipf.rvs(1.5)
        assert_(isinstance(val, int))
        val = stats.zipf(1.5).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_rvs(self):
        vals = stats.zipf.rvs(1.5, size=(2, 50))
        assert_(numpy.all(vals >= 1))
        assert_(numpy.shape(vals) == (2, 50))
        assert_(vals.dtype.char in typecodes['AllInteger'])
        val = stats.zipf.rvs(1.5)
        assert_(isinstance(val, int))
        val = stats.zipf(1.5).rvs(3)
        assert_(isinstance(val, numpy.ndarray))
        assert_(val.dtype.char in typecodes['AllInteger'])
//  [python]
def test_all(self):
        a = np.random.normal(0, 1, (4, 5, 6, 7, 8))
        for i in range(a.ndim):
            amax = a.max(i)
            aargmax = a.argmax(i)
            axes = list(range(a.ndim))
            axes.remove(i)
            assert_(np.all(amax == aargmax.choose(*a.transpose(i,*axes))))
//  [python]
def test_all(self):
        a = np.random.normal(0, 1, (4, 5, 6, 7, 8))
        for i in range(a.ndim):
            amin = a.min(i)
            aargmin = a.argmin(i)
            axes = list(range(a.ndim))
            axes.remove(i)
            assert_(np.all(amin == aargmin.choose(*a.transpose(i,*axes))))
//  [python]
def assert_all(x):
    assert_(n.all(x), x)
//  [python]
def assert_all(x):
    assert_(np.all(x), x)
//  [python]
def is_pos_semidef(x, tol=1e-15):
    """Check if x is positive semi-definite."""
    eigs = np.linalg.eigvalsh(x)
    eigs[np.abs(eigs) < tol] = 0
    return n.all(eigs >= 0)
//  [python]
def is_pos_semidef(x, tol=1e-15):
    """Check if x is positive semi-definite."""
    eigs = np.linalg.eigvalsh(x)
    eigs[np.abs(eigs) < tol] = 0
    return np.all(eigs >= 0)
//  [python]
def is_pos_def(x, tol=1e-15, chol=True):
    """Check if x is positive definite."""
    if chol:
        try:
            np.linalg.cholesky(x)
            return True
        except LinAlgError:
            return False

    eigs = np.linalg.eigvalsh(x)
    eigs[np.abs(eigs) < tol] = 0
    return n.all(eigs > 0)
//  [python]
def is_pos_def(x, tol=1e-15, chol=True):
    """Check if x is positive definite."""
    if chol:
        try:
            np.linalg.cholesky(x)
            return True
        except LinAlgError:
            return False

    eigs = np.linalg.eigvalsh(x)
    eigs[np.abs(eigs) < tol] = 0
    return np.all(eigs > 0)
//  [python]
def test_goodvalues(self):
        z = np.array((-1., 0., 1.))
        res = np.isnan(z) == 0
        assert_(np.all(res, axis=0))
//  [python]
def test_goodvalues(self):
        z = np.array((-1., 0., 1.))
        res = np.isnan(z) == 0
        assert_all(np.all(res, axis=0))
//  [python]
def test_goodvalues(self):
        z = np.array((-1., 0., 1.))
        res = np.isfinite(z) == 1
        assert_all(np.all(res, axis=0))
//  [python]
def constant(x):
    # pass through numpy scalars, since they are already typed on
    # purpose typically.
    if hasattr(x, 'dtype'):
        assert x.ndim == 0
        return ScalarConstant(get_scalar_type(str(x.dtype)), x)
    if isinstance(x, builtin_float):
        for dtype in ['float32', 'float64']:
            x_ = theano._asarray(x, dtype=dtype)
            if n.all(x == x_):
                break
            x_ = None
        assert x_ is not None
        return ScalarConstant(get_scalar_type(str(x_.dtype)), x)
    if isinstance(x, builtin_int):
        for dtype in ['int8', 'int16', 'int32', 'int64']:
            x_ = theano._asarray(x, dtype=dtype)
            if n.all(x == x_):
                break
            x_ = None
        assert x_ is not None
        return ScalarConstant(get_scalar_type(str(x_.dtype)), x)
    if isinstance(x, builtin_complex):
        # TODO: We have added the complex type, so this should be tested
        raise NotImplementedError()
    raise TypeError(x)
//  [python]
def constant(x):
    # pass through numpy scalars, since they are already typed on
    # purpose typically.
    if hasattr(x, 'dtype'):
        assert x.ndim == 0
        return ScalarConstant(get_scalar_type(str(x.dtype)), x)
    if isinstance(x, builtin_float):
        for dtype in ['float32', 'float64']:
            x_ = theano._asarray(x, dtype=dtype)
            if numpy.all(x == x_):
                break
            x_ = None
        assert x_ is not None
        return ScalarConstant(get_scalar_type(str(x_.dtype)), x)
    if isinstance(x, builtin_int):
        for dtype in ['int8', 'int16', 'int32', 'int64']:
            x_ = theano._asarray(x, dtype=dtype)
            if numpy.all(x == x_):
                break
            x_ = None
        assert x_ is not None
        return ScalarConstant(get_scalar_type(str(x_.dtype)), x)
    if isinstance(x, builtin_complex):
        # TODO: We have added the complex type, so this should be tested
        raise NotImplementedError()
    raise TypeError(x)
//  [python]
def test_goodvalues(self):
        z = np.array((-1., 0., 1.))
        res = np.isinf(z) == 0
        assert_(np.all(res, axis=0))
//  [python]
def test_goodvalues(self):
        z = np.array((-1., 0., 1.))
        res = np.isinf(z) == 0
        assert_all(np.all(res, axis=0))
//  [python]
def test_simple(self):
        # check that unwrap removes jumps greather that 2*pi
        assert_array_equal(unwrap([1, 1 + 2 * np.pi]), [1, 1])
        # check that unwrap maintans continuity
        assert_(all(diff(unwrap(rand(10) * 100)) < np.pi))
//  [python]
def test_simple(self):
        # check that unwrap removes jumps greather that 2*pi
        assert_array_equal(unwrap([1, 1 + 2 * np.pi]), [1, 1])
        # check that unwrap maintans continuity
        assert_(np.all(diff(unwrap(rand(10) * 100)) < np.pi))
//  [python]
def test_int_negative_interval(self):
        assert_(-5 <= random.randint(-5, -1) < -1)
        x = random.randint(-5, -1, 5)
        assert_(n.all(-5 <= x))
        assert_(n.all(x < -1))
//  [python]
def test_int_negative_interval(self):
        assert_(-5 <= random.randint(-5, -1) < -1)
        x = random.randint(-5, -1, 5)
        assert_(np.all(-5 <= x))
        assert_(np.all(x < -1))