How to use the nose.tools.assert_almost_equal function in nose

To help you get started, we’ve selected a few nose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github probcomp / Venturecxx / test / inference_language / test_optimization_inference_plugin.py View on Github external
options={'disp': True}
        )
        print res_bfgs.x
        print "================"
        print "Conjugate gradient"
        res_cg = minimize(
            logpdf,
            [mu_0, std_0],
            method='CG',
            jac=der_logpdf,
            options={'disp': True}
        )
        print res_cg
        print "================"
    decimals = 4
    assert_almost_equal(res_nelder_mead.x[0], mu_after_ascent, places=decimals)
    assert_almost_equal(res_nelder_mead.x[1], std_after_ascent, places=decimals)

    assert_almost_equal(res_bfgs.x[0], mu_after_ascent, places=decimals)
    assert_almost_equal(res_bfgs.x[1], std_after_ascent, places=decimals)

    assert_almost_equal(res_cg.x[0], mu_after_ascent, places=decimals)
    assert_almost_equal(res_cg.x[1], std_after_ascent, places=decimals)
github cokelaer / spectrum / test / test_correlog.py View on Github external
def test_correlog():
    psd = CORRELOGRAMPSD(marple_data, marple_data, lag=15)
    assert_almost_equal(psd[0],      0.138216970)
    assert_almost_equal(psd[1000-1], 7.900110787)
    assert_almost_equal(psd[2000-1], 0.110103858)
    assert_almost_equal(psd[3000-1], 0.222184134)
    assert_almost_equal(psd[4000-1], -0.036255277)
    assert_almost_equal(psd[4096-1], 0.1391839711)
    return psd
github bowman-lab / enspara / enspara / cards / test_cards.py View on Github external
def assert_correlates(m1, m2):
    assert_almost_equal(pearsonr(m1.flatten(), m2.flatten())[0], 1,
                        places=14)
github EducationalTestingService / rsmtool / tests / test_utils_prmse.py View on Github external
def test_mse_sparse_matrix_computed_ve(self):
        human_scores = self.human_score_columns
        df_humans = self.data_sparse[human_scores]
        system = self.data_sparse['system']
        expected_mse_true = 0.3550792
        mse = mse_true(system,
                       df_humans)
        assert_almost_equal(mse, expected_mse_true, 7)
github cuspaceflight / tawhiri / tests / test_models.py View on Github external
40000.0: -88.62441475
            },
            10.0: {
                0.0: -9.97267806,
                1000.0: -10.46805022,
                20000.0: -37.02915694,
                40000.0: -177.24882949
            }
        }
        for sldr in checks:
            f = models.make_drag_descent(sldr)
            for alt in checks[sldr]:
                _a, _b, rate = f(0, 0, 0, alt)
                assert_equal(_a, 0.0)
                assert_equal(_b, 0.0)
                assert_almost_equal(rate, checks[sldr][alt])
github cokelaer / spectrum / test / test_levinson.py View on Github external
def test_levinson_real():
    r = [5.0000, -1.5450, -3.9547, 3.9331, 1.4681, -4.7500]
    A, E, K = LEVINSON(r)
    assert_array_almost_equal(A, numpy.array([  6.14739427e-01,   9.89813712e-01,   4.20968656e-04,
         3.44472001e-03,  -7.70967347e-03]))
    assert_almost_equal(0.1791451516, E)


    A, E,k = LEVINSON([1, 0.5,0.3],1)
    for a1, a2 in zip(A, [-0.5]):
        assert_almost_equal(a1, a2)
    assert_almost_equal(E, 0.75)


    A, E, K = LEVINSON([1,0.5,0.1,0.05])
    assert_array_almost_equal(A, (array([-0.625,  0.275, -0.125])))
    assert_array_almost_equal(E, 0.708749)
    assert_array_almost_equal(K, array([-0.5  ,  0.2  , -0.125]))
github DiamondLightSource / diffcalc / test / test_numjy.py View on Github external
def test__div__(self):
        r = self.m('1 2; 3 4') / self.m('5. 6.; 7. 8.')
        assert_almost_equal(r[0, 0], .2)
        assert_almost_equal(r[0, 1], .33333333)
        assert_almost_equal(r[1, 0], 0.42857143)
        assert_almost_equal(r[1, 1], .5)
github DiamondLightSource / diffcalc / test / test_numjy.py View on Github external
def test_I(self):
        inverse = self.m('1 2; 3 4').I
        assert_almost_equal(inverse[0, 0], -2)
        assert_almost_equal(inverse[0, 1], 1)
        assert_almost_equal(inverse[1, 0], 1.5)
        assert_almost_equal(inverse[1, 1], -.5)
github dreamtools / dreamtools / test / dream8 / test_d8c2.py View on Github external
def test_sc2():
    s = D8C2()
    filename = s.download_template('sc2')
    df = s.score(filename, 'sc2')#
    assert_almost_equal(df['SC_m']['bestPerformer'], 0.45085234093637499564)