Пример #1
0
def test_fake_nodes_factory():
    """Test FakeNodesFactory in a specific regime in which the fake nodes
    interpolation method works well.
    """
    fac = FakeNodesFactory(UNIFORM_X)
    assert not fac._opt_params
    fac.run_classical(f_runge)
    zne_value = fac.reduce()
    assert np.isclose(zne_value, f_runge(0.0), atol=LARGE_TOL)
    assert len(fac._opt_params) == len(UNIFORM_X)
    assert np.isclose(fac._opt_params[-1], zne_value)
Пример #2
0
def test_fake_nodes_factory():
    """Test FakeNodesFactory in a specific regime in which the fake nodes
    interpolation method works well.
    """
    fac = FakeNodesFactory(UNIFORM_X)
    assert not fac._opt_params
    fac.run_classical(f_runge)
    zne_value = fac.reduce()
    assert np.isclose(zne_value, f_runge(0.0), atol=LARGE_TOL)
    assert len(fac._opt_params) == len(UNIFORM_X)
    assert np.isclose(fac._opt_params[-1], zne_value)
    assert np.isclose(fac.extrapolate(UNIFORM_X, f_runge(UNIFORM_X)),
                      zne_value)
    exp_vals = fac.get_expectation_values()
    assert np.isclose(fac.extrapolate(UNIFORM_X, exp_vals), zne_value)
    assert np.isclose(
        fac.extrapolate(UNIFORM_X, exp_vals, full_output=True)[0],
        zne_value,
    )