numpy.eye

Here are the examples of the python api numpy.eye taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3862 Examples 7

5 Source : test_constraint_utilities.py
with MIT License
from TAMUparametric

def test_facet_ball_elimination():
    A = numpy.block([[numpy.eye(2)], [-numpy.eye(2)]])
    b = numpy.array([[1], [1], [0], [0]])

    A_t = numpy.block([[numpy.eye(2)], [-numpy.eye(2)], [numpy.array([[1, 1]])]])
    b_t = numpy.array([[2], [2], [0], [0], [1]])

    A_r = numpy.block([[A], [A_t]])
    b_r = numpy.block([[b], [b_t]])

    [_, _] = process_region_constraints(A_r, b_r)

5 Source : test_critical_region.py
with MIT License
from TAMUparametric

def region() -> CriticalRegion:
    """A square critical region with predictable properties."""
    A = numpy.eye(2)
    b = numpy.zeros((2, 1))
    C = numpy.eye(2)
    d = numpy.zeros((2, 1))
    E = numpy.block([[numpy.eye(2)], [-numpy.eye(2)]])
    f = make_column([1, 1, 0, 0])
    return CriticalRegion(A, b, C, d, E, f, [])

def test_docs(region):

5 Source : test_mp_program.py
with MIT License
from TAMUparametric

def linear_program() -> MPLP_Program:
    """a simple mplp to test the dimensional correctness of its functions"""
    A = numpy.eye(3)
    b = numpy.zeros((3, 1))
    F = numpy.ones((3, 10))
    A_t = numpy.block([[-numpy.eye(5)], [numpy.eye(5)]])
    b_t = numpy.ones((10, 1))
    c = numpy.ones((3, 1))
    H = numpy.zeros((A.shape[1], F.shape[1]))
    return MPLP_Program(A, b, c, H, A_t, b_t, F, [0])


@pytest.fixture()

5 Source : test_fixtures.py
with MIT License
from TAMUparametric

def region() -> CriticalRegion:
    """A square critical region with predictable properties."""
    A = numpy.eye(2)
    b = numpy.zeros((2, 1))
    C = numpy.eye(2)
    d = numpy.zeros((2, 1))
    E = numpy.block([[numpy.eye(2)], [-numpy.eye(2)]])
    f = make_column([1, 1, 0, 0])
    return CriticalRegion(A, b, C, d, E, f, [])


@pytest.fixture()

5 Source : test_fixtures.py
with MIT License
from TAMUparametric

def linear_program() -> MPLP_Program:
    """A simple mplp to test the dimensional correctness of its functions."""
    A = numpy.eye(3)
    b = numpy.zeros((3, 1))
    F = numpy.ones((3, 10))
    A_t = numpy.block([[-numpy.eye(5)], [numpy.eye(5)]])
    b_t = numpy.ones((10, 1))
    c = numpy.ones((3, 1))
    H = numpy.zeros((A.shape[1], F.shape[1]))
    return MPLP_Program(A, b, c, H, A_t, b_t, F, [0])


@pytest.fixture()

3 Source : m_gpflow.py
with MIT License
from AaltoML

    def inv(K):
        K_chol = sp.linalg.cholesky(K + jit * np.eye(M), lower=True)
        return sp.linalg.cho_solve((K_chol, True), np.eye(K.shape[0]))

    # manual q(u) decompositin
    nat1 = np.zeros([M, 1])

3 Source : ppbo_numerical_main.py
with MIT License
from AaltoPML

def hartmann6d(traj):
    PPBO_settings_ = PPBO_settings(D=6,bounds=((0, 1),)*6,
                                   xi_acquisition_function=traj.xi_acquisition_function,m=traj.m,
                                   theta_initial=[0.001,0.26,0.1],alpha_grid_distribution='TGN') #[0.001,0.26,0.1], [1,0.1,8]
    initial_queries_xi = np.eye(PPBO_settings_.D)
    np.random.seed(traj.initialization_seed) 
    initial_queries_x = np.random.uniform([PPBO_settings_.original_bounds[i][0] for i in range(PPBO_settings_.D)], [PPBO_settings_.original_bounds[i][1] for i in range(PPBO_settings_.D)], (len(initial_queries_xi), PPBO_settings_.D))
    results,xstar_results,mustar_results,GP_model = run_ppbo_loop('hartmann6d',initial_queries_xi,initial_queries_x,traj.number_of_actual_queries,PPBO_settings_)
    traj.f_add_result('xstar',xstar_results)
    traj.f_add_result('mustar',mustar_results)
    return GP_model

''' Run experimetns '''

3 Source : acquisition.py
with MIT License
from AaltoPML

def EId_xstar(GP_model,mc_samples):
    ''' Returns the dimension that maximizes EI given x=xstar '''
    xstar = GP_model.xstar.copy()
    EIvals = [0]*GP_model.D
    xis = np.eye(GP_model.D)
    for d in range(GP_model.D):
        xi = xis[d]
        xstar_ = xstar.copy()
        xstar_[d] = 0
        EIvals[d] = EI(xi,xstar_,GP_model,mc_samples)
    dstar = np.argmax(EIvals)
    xistar = xis[dstar] #best standard unit vector
    xstar[dstar] = 0
    return xistar
def EId_integrate(GP_model,mc_samples):

3 Source : acquisition.py
with MIT License
from AaltoPML

def PCD_next_xi(PPBO_settings):
    I = np.eye(PPBO_settings.D)
    d = int(PPBO_settings.dim_query_prev_iter + 1)
    if d > PPBO_settings.D:
        d = 1
    PPBO_settings.dim_query_prev_iter = d
    return I[:,d-1]

def EXT_next_xi(PPBO_settings,GP_model):

3 Source : align.py
with MIT License
from abel-research

    def __init__(self, moving, static, method = 'linPoint2Plane', 
                inverse=False, *args, **kwargs):
        mData = dict(zip(['vert', 'faces', 'values'], 
                         [moving.vert, moving.faces, moving.values]))
        alData = copy.deepcopy(mData)
        self.setMoving(AmpObject(alData, stype='reg'))
        self.setStatic(static)
        self.R = np.eye(3)
        self.T = np.zeros(3)
        self.tForm = np.eye(4)
        self.rmse = 0

        if inverse:
            self.inverse(method=method, *args, **kwargs)
        else:
            self.runICP(method=method, *args, **kwargs)

    def setStatic(self, amp):

3 Source : test_transform.py
with Apache License 2.0
from Accenture

def assert_is_translation(transform, min, max):
    assert transform.shape == (3, 3)
    assert np.array_equal(transform[:, 0:2], np.eye(3, 2))
    assert transform[2, 2] == 1
    assert np.greater_equal(transform[0:2, 2], min).all()
    assert np.less(         transform[0:2, 2], max).all()


def test_random_translation():

3 Source : test_numpy_routines.py
with GNU General Public License v3.0
from ad12

    def test_clip(self):
        # Clip
        shape = (10, 20, 30)
        mv = MedicalVolume(np.random.rand(*shape), np.eye(4))

        mv2 = np.clip(mv, 0.4, 0.6)
        assert np.all((mv2.volume >= 0.4) & (mv2.volume   <  = 0.6))

        mv_lower = MedicalVolume(np.ones(mv.shape) * 0.4, mv.affine)
        mv_upper = MedicalVolume(np.ones(mv.shape) * 0.6, mv.affine)
        mv2 = np.clip(mv, mv_lower, mv_upper)
        assert np.all((mv2.volume >= 0.4) & (mv2.volume  < = 0.6))

    def test_array_like(self):

3 Source : test_numpy_routines.py
with GNU General Public License v3.0
from ad12

    def test_array_like(self):
        shape = (10, 20, 30)
        mv = MedicalVolume(np.random.rand(*shape), np.eye(4))

        mv2 = np.zeros_like(mv)
        assert np.all(mv2.volume == 0)

        mv2 = np.ones_like(mv)
        assert np.all(mv2.volume == 1)

    def test_shares_memory(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_keepdims(self):
        mat = np.eye(3)
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            for axis in [None, 0, 1]:
                tgt = rf(mat, axis=axis, keepdims=True)
                res = nf(mat, axis=axis, keepdims=True)
                assert_(res.ndim == tgt.ndim)

    def test_out(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_out(self):
        mat = np.eye(3)
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            resout = np.zeros(3)
            tgt = rf(mat, axis=1)
            res = nf(mat, axis=1, out=resout)
            assert_almost_equal(res, resout)
            assert_almost_equal(res, tgt)

    def test_dtype_from_input(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_dtype_from_input(self):
        codes = 'efdgFDG'
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            for c in codes:
                mat = np.eye(3, dtype=c)
                tgt = rf(mat, axis=1).dtype.type
                res = nf(mat, axis=1).dtype.type
                assert_(res is tgt)
                # scalar case
                tgt = rf(mat, axis=None).dtype.type
                res = nf(mat, axis=None).dtype.type
                assert_(res is tgt)

    def test_result_values(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_matrices(self):
        # Check that it works and that type and
        # shape are preserved
        mat = np.matrix(np.eye(3))
        for f in self.nanfuncs:
            res = f(mat, axis=0)
            assert_(isinstance(res, np.matrix))
            assert_(res.shape == (1, 3))
            res = f(mat, axis=1)
            assert_(isinstance(res, np.matrix))
            assert_(res.shape == (3, 1))
            res = f(mat)
            assert_(np.isscalar(res))


class TestNanFunctions_IntTypes(object):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_out(self):
        mat = np.eye(3)
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            resout = np.zeros(3)
            tgt = rf(mat, axis=1)
            res = nf(mat, axis=1, out=resout)
            assert_almost_equal(res, resout)
            assert_almost_equal(res, tgt)

    def test_dtype_from_dtype(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_dtype_from_dtype(self):
        mat = np.eye(3)
        codes = 'efdgFDG'
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            for c in codes:
                with suppress_warnings() as sup:
                    if nf in {np.nanstd, np.nanvar} and c in 'FDG':
                        # Giving the warning is a small bug, see gh-8000
                        sup.filter(np.ComplexWarning)
                    tgt = rf(mat, dtype=np.dtype(c), axis=1).dtype.type
                    res = nf(mat, dtype=np.dtype(c), axis=1).dtype.type
                    assert_(res is tgt)
                    # scalar case
                    tgt = rf(mat, dtype=np.dtype(c), axis=None).dtype.type
                    res = nf(mat, dtype=np.dtype(c), axis=None).dtype.type
                    assert_(res is tgt)

    def test_dtype_from_char(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_dtype_from_char(self):
        mat = np.eye(3)
        codes = 'efdgFDG'
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            for c in codes:
                with suppress_warnings() as sup:
                    if nf in {np.nanstd, np.nanvar} and c in 'FDG':
                        # Giving the warning is a small bug, see gh-8000
                        sup.filter(np.ComplexWarning)
                    tgt = rf(mat, dtype=c, axis=1).dtype.type
                    res = nf(mat, dtype=c, axis=1).dtype.type
                    assert_(res is tgt)
                    # scalar case
                    tgt = rf(mat, dtype=c, axis=None).dtype.type
                    res = nf(mat, dtype=c, axis=None).dtype.type
                    assert_(res is tgt)

    def test_dtype_from_input(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_dtype_from_input(self):
        codes = 'efdgFDG'
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            for c in codes:
                mat = np.eye(3, dtype=c)
                tgt = rf(mat, axis=1).dtype.type
                res = nf(mat, axis=1).dtype.type
                assert_(res is tgt, "res %s, tgt %s" % (res, tgt))
                # scalar case
                tgt = rf(mat, axis=None).dtype.type
                res = nf(mat, axis=None).dtype.type
                assert_(res is tgt)

    def test_result_values(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_matrices(self):
        # Check that it works and that type and
        # shape are preserved
        mat = np.matrix(np.eye(3))
        for f in self.nanfuncs:
            res = f(mat, axis=0)
            assert_(isinstance(res, np.matrix))
            assert_(res.shape == (1, 3))
            res = f(mat, axis=1)
            assert_(isinstance(res, np.matrix))
            assert_(res.shape == (3, 1))
            res = f(mat)
            assert_(np.isscalar(res))


class TestNanFunctions_SumProd(SharedNanFunctionsTestsMixin):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_matrices(self):
        # Check that it works and that type and
        # shape are preserved
        mat = np.matrix(np.eye(3))
        for f in self.nanfuncs:
            for axis in np.arange(2):
                res = f(mat, axis=axis)
                assert_(isinstance(res, np.matrix))
                assert_(res.shape == (3, 3))
            res = f(mat)
            assert_(res.shape == (1, 3*3))

    def test_result_values(self):

3 Source : test_nanfunctions.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_out(self):
        mat = np.eye(3)
        for nf, rf in zip(self.nanfuncs, self.stdfuncs):
            resout = np.eye(3)
            for axis in (-2, -1, 0, 1):
                tgt = rf(mat, axis=axis)
                res = nf(mat, axis=axis, out=resout)
                assert_almost_equal(res, resout)
                assert_almost_equal(res, tgt)


class TestNanFunctions_MeanVarStd(SharedNanFunctionsTestsMixin):

3 Source : test_twodim_base.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_basic(self):
        assert_equal(eye(4),
                     array([[1, 0, 0, 0],
                            [0, 1, 0, 0],
                            [0, 0, 1, 0],
                            [0, 0, 0, 1]]))

        assert_equal(eye(4, dtype='f'),
                     array([[1, 0, 0, 0],
                            [0, 1, 0, 0],
                            [0, 0, 1, 0],
                            [0, 0, 0, 1]], 'f'))

        assert_equal(eye(3) == 1,
                     eye(3, dtype=bool))

    def test_diag(self):

3 Source : test_twodim_base.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_diag(self):
        assert_equal(eye(4, k=1),
                     array([[0, 1, 0, 0],
                            [0, 0, 1, 0],
                            [0, 0, 0, 1],
                            [0, 0, 0, 0]]))

        assert_equal(eye(4, k=-1),
                     array([[0, 0, 0, 0],
                            [1, 0, 0, 0],
                            [0, 1, 0, 0],
                            [0, 0, 1, 0]]))

    def test_2d(self):

3 Source : test_twodim_base.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_2d(self):
        assert_equal(eye(4, 3),
                     array([[1, 0, 0],
                            [0, 1, 0],
                            [0, 0, 1],
                            [0, 0, 0]]))

        assert_equal(eye(3, 4),
                     array([[1, 0, 0, 0],
                            [0, 1, 0, 0],
                            [0, 0, 1, 0]]))

    def test_diag2d(self):

3 Source : test_twodim_base.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_diag2d(self):
        assert_equal(eye(3, 4, k=2),
                     array([[0, 0, 1, 0],
                            [0, 0, 0, 1],
                            [0, 0, 0, 0]]))

        assert_equal(eye(4, 3, k=-2),
                     array([[0, 0, 0],
                            [0, 0, 0],
                            [1, 0, 0],
                            [0, 1, 0]]))

    def test_eye_bounds(self):

3 Source : test_twodim_base.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_eye_bounds(self):
        assert_equal(eye(2, 2, 1), [[0, 1], [0, 0]])
        assert_equal(eye(2, 2, -1), [[0, 0], [1, 0]])
        assert_equal(eye(2, 2, 2), [[0, 0], [0, 0]])
        assert_equal(eye(2, 2, -2), [[0, 0], [0, 0]])
        assert_equal(eye(3, 2, 2), [[0, 0], [0, 0], [0, 0]])
        assert_equal(eye(3, 2, 1), [[0, 1], [0, 0], [0, 0]])
        assert_equal(eye(3, 2, -1), [[0, 0], [1, 0], [0, 1]])
        assert_equal(eye(3, 2, -2), [[0, 0], [0, 0], [1, 0]])
        assert_equal(eye(3, 2, -3), [[0, 0], [0, 0], [0, 0]])

    def test_strings(self):

3 Source : test_twodim_base.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_order(self):
        mat_c = eye(4, 3, k=-1)
        mat_f = eye(4, 3, k=-1, order='F')
        assert_equal(mat_c, mat_f)
        assert mat_c.flags.c_contiguous
        assert not mat_c.flags.f_contiguous
        assert not mat_f.flags.c_contiguous
        assert mat_f.flags.f_contiguous


class TestDiag(object):

3 Source : test_deprecations.py
with GNU General Public License v3.0
from adityaprakash-bobby

def test_qr_mode_full_future_warning():
    """Check mode='full' FutureWarning.

    In numpy 1.8 the mode options 'full' and 'economic' in linalg.qr were
    deprecated. The release date will probably be sometime in the summer
    of 2013.

    """
    a = np.eye(2)
    assert_warns(DeprecationWarning, np.linalg.qr, a, mode='full')
    assert_warns(DeprecationWarning, np.linalg.qr, a, mode='f')
    assert_warns(DeprecationWarning, np.linalg.qr, a, mode='economic')
    assert_warns(DeprecationWarning, np.linalg.qr, a, mode='e')


if __name__ == "__main__":

3 Source : test_linalg.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_symmetric_rank(self):
        yield assert_equal, 4, matrix_rank(np.eye(4), hermitian=True)
        yield assert_equal, 1, matrix_rank(np.ones((4, 4)), hermitian=True)
        yield assert_equal, 0, matrix_rank(np.zeros((4, 4)), hermitian=True)
        # rank deficient matrix
        I = np.eye(4)
        I[-1, -1] = 0.
        yield assert_equal, 3, matrix_rank(I, hermitian=True)
        # manually supplied tolerance
        I[-1, -1] = 1e-8
        yield assert_equal, 4, matrix_rank(I, hermitian=True, tol=0.99e-8)
        yield assert_equal, 3, matrix_rank(I, hermitian=True, tol=1.01e-8)


def test_reduced_rank():

3 Source : test_regression.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_large_svd_32bit(self):
        # See gh-4442, 64bit would require very large/slow matrices.
        x = np.eye(1000, 66)
        np.linalg.svd(x)

    def test_svd_no_uv(self):

3 Source : test_core.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_asarray_default_order(self):
        # See Issue #6646
        m = np.eye(3).T
        assert_(not m.flags.c_contiguous)

        new_m = asarray(m)
        assert_(new_m.flags.c_contiguous)

    def test_asarray_enforce_order(self):

3 Source : test_core.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_asarray_enforce_order(self):
        # See Issue #6646
        m = np.eye(3).T
        assert_(not m.flags.c_contiguous)

        new_m = asarray(m, order='C')
        assert_(new_m.flags.c_contiguous)

    def test_fix_invalid(self):

3 Source : test_extras.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_dot_returns_maskedarray(self):
        # See gh-6611
        a = np.eye(3)
        b = array(a)
        assert_(type(dot(a, a)) is MaskedArray)
        assert_(type(dot(a, b)) is MaskedArray)
        assert_(type(dot(b, a)) is MaskedArray)
        assert_(type(dot(b, b)) is MaskedArray)

    def test_dot_out(self):

3 Source : test_extras.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_dot_out(self):
        a = array(np.eye(3))
        out = array(np.zeros((3, 3)))
        res = dot(a, a, out=out)
        assert_(res is out)
        assert_equal(a, res)


class TestApplyAlongAxis(object):

3 Source : test_defmatrix.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_row_column_indexing(self):
        x = asmatrix(np.eye(2))
        assert_array_equal(x[0,:], [[1, 0]])
        assert_array_equal(x[1,:], [[0, 1]])
        assert_array_equal(x[:, 0], [[1], [0]])
        assert_array_equal(x[:, 1], [[0], [1]])

    def test_boolean_indexing(self):

3 Source : test_regression.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_matrix_multiply_by_1d_vector(self):
        # Ticket #473
        def mul():
            np.mat(np.eye(2))*np.ones(2)

        assert_raises(ValueError, mul)

    def test_matrix_std_argmax(self):

3 Source : rbf.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def A(self):
        # this only exists for backwards compatibility: self.A was available
        # and, at least technically, public.
        r = self._call_norm(self.xi, self.xi)
        return self._init_function(r) - np.eye(self.N)*self.smooth

    def _call_norm(self, x1, x2):

3 Source : test_mio.py
with GNU General Public License v3.0
from adityaprakash-bobby

def test_sparse_in_struct():
    # reproduces bug found by DC where Cython code was insisting on
    # ndarray return type, but getting sparse matrix
    st = {'sparsefield': SP.coo_matrix(np.eye(4))}
    stream = BytesIO()
    savemat(stream, {'a':st})
    d = loadmat(stream, struct_as_record=True)
    assert_array_equal(d['a'][0,0]['sparsefield'].todense(), np.eye(4))


def test_mat_struct_squeeze():

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_empty_rhs(self):
        a = np.eye(2)
        b = [[], []]
        x = solve(a, b)
        assert_(x.size == 0, 'Returned array is not empty')
        assert_(x.shape == (2, 0), 'Returned empty array shape is wrong')

    def test_multiple_rhs(self):

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_multiple_rhs(self):
        a = np.eye(2)
        b = np.random.rand(2, 3, 4)
        x = solve(a, b)
        assert_array_almost_equal(x, b)

    def test_transposed_keyword(self):

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_transposed_notimplemented(self):
        a = np.eye(3).astype(complex)
        with assert_raises(NotImplementedError):
            solve(a, a, transposed=True)

    def test_nonsquare_a(self):

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_simple(self):
        a = [[1, 2], [3, 4]]
        a_inv = inv(a)
        assert_array_almost_equal(dot(a, a_inv), np.eye(2))
        a = [[1, 2, 3], [4, 5, 6], [7, 8, 10]]
        a_inv = inv(a)
        assert_array_almost_equal(dot(a, a_inv), np.eye(3))

    def test_random(self):

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_simple_real(self):
        a = array([[1, 2, 3], [4, 5, 6], [7, 8, 10]], dtype=float)
        a_pinv = pinv(a)
        assert_array_almost_equal(dot(a, a_pinv), np.eye(3))
        a_pinv = pinv2(a)
        assert_array_almost_equal(dot(a, a_pinv), np.eye(3))

    def test_simple_complex(self):

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_simple_complex(self):
        a = (array([[1, 2, 3], [4, 5, 6], [7, 8, 10]],
             dtype=float) + 1j * array([[10, 8, 7], [6, 5, 4], [3, 2, 1]],
                                       dtype=float))
        a_pinv = pinv(a)
        assert_array_almost_equal(dot(a, a_pinv), np.eye(3))
        a_pinv = pinv2(a)
        assert_array_almost_equal(dot(a, a_pinv), np.eye(3))

    def test_simple_singular(self):

3 Source : test_basic.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_check_finite(self):
        a = array([[1, 2, 3], [4, 5, 6.], [7, 8, 10]])
        a_pinv = pinv(a, check_finite=False)
        assert_array_almost_equal(dot(a, a_pinv), np.eye(3))
        a_pinv = pinv2(a, check_finite=False)
        assert_array_almost_equal(dot(a, a_pinv), np.eye(3))

    def test_native_list_argument(self):

3 Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_simple3(self):
        a = np.eye(3)
        a[-1, 0] = 2
        h, q = hessenberg(a, calc_q=1)
        assert_array_almost_equal(dot(transp(q), dot(a, q)), h)

    def test_random(self):

3 Source : test_decomp.py
with GNU General Public License v3.0
from adityaprakash-bobby

    def test_2x2(self):
        a = [[2, 1], [7, 12]]

        h, q = hessenberg(a, calc_q=1)
        assert_array_almost_equal(q, np.eye(2))
        assert_array_almost_equal(h, a)

        b = [[2-7j, 1+2j], [7+3j, 12-2j]]
        h2, q2 = hessenberg(b, calc_q=1)
        assert_array_almost_equal(q2, np.eye(2))
        assert_array_almost_equal(h2, b)


class TestQZ(object):

See More Examples