def test_fit_exponential_decays(): rs = np.random.RandomState(999) cycle_depths = np.arange(3, 100, 11) fidelities = 0.95 * 0.98 ** cycle_depths + rs.normal(0, 0.2) a, layer_fid, a_std, layer_fid_std = _fit_exponential_decay(cycle_depths, fidelities) np.testing.assert_allclose([a, layer_fid], [0.95, 0.98], atol=0.02) assert 0 < a_std < 0.2 / len(cycle_depths) assert 0 < layer_fid_std < 1e-3
def test_fit_exponential_decays_negative_fids(): rs = np.random.RandomState(999) cycle_depths = np.arange(3, 100, 11) fidelities = 0.5 * 0.5 ** cycle_depths + rs.normal(0, 0.2) - 0.5 assert np.sum(fidelities > 0) <= 1, 'they go negative' a, layer_fid, a_std, layer_fid_std = _fit_exponential_decay(cycle_depths, fidelities) assert a == 0 assert layer_fid == 0 assert a_std == np.inf assert layer_fid_std == np.inf