| 80 | |
| 81 | |
| 82 | def test_aampi_self_join_egress(): |
| 83 | m = 3 |
| 84 | |
| 85 | for p in [1.0, 2.0, 3.0]: |
| 86 | seed = np.random.randint(100000) |
| 87 | np.random.seed(seed) |
| 88 | |
| 89 | n = 30 |
| 90 | T = np.random.rand(n) |
| 91 | |
| 92 | ref_mp = naive.aampi_egress(T, m, p=p) |
| 93 | ref_P = ref_mp.P_.copy() |
| 94 | ref_I = ref_mp.I_ |
| 95 | ref_left_P = ref_mp.left_P_.copy() |
| 96 | ref_left_I = ref_mp.left_I_ |
| 97 | |
| 98 | stream = aampi(T, m, egress=True, p=p) |
| 99 | |
| 100 | comp_P = stream.P_.copy() |
| 101 | comp_I = stream.I_ |
| 102 | comp_left_P = stream.left_P_.copy() |
| 103 | comp_left_I = stream.left_I_ |
| 104 | |
| 105 | naive.replace_inf(ref_P) |
| 106 | naive.replace_inf(ref_left_P) |
| 107 | naive.replace_inf(comp_P) |
| 108 | naive.replace_inf(comp_left_P) |
| 109 | |
| 110 | npt.assert_almost_equal(ref_P, comp_P) |
| 111 | npt.assert_almost_equal(ref_I, comp_I) |
| 112 | npt.assert_almost_equal(ref_left_P, comp_left_P) |
| 113 | npt.assert_almost_equal(ref_left_I, comp_left_I) |
| 114 | |
| 115 | for i in range(34): |
| 116 | t = np.random.rand() |
| 117 | |
| 118 | ref_mp.update(t) |
| 119 | stream.update(t) |
| 120 | |
| 121 | comp_P = stream.P_.copy() |
| 122 | comp_I = stream.I_ |
| 123 | comp_left_P = stream.left_P_.copy() |
| 124 | comp_left_I = stream.left_I_ |
| 125 | |
| 126 | ref_P = ref_mp.P_.copy() |
| 127 | ref_I = ref_mp.I_ |
| 128 | ref_left_P = ref_mp.left_P_.copy() |
| 129 | ref_left_I = ref_mp.left_I_ |
| 130 | |
| 131 | naive.replace_inf(ref_P) |
| 132 | naive.replace_inf(ref_left_P) |
| 133 | naive.replace_inf(comp_P) |
| 134 | naive.replace_inf(comp_left_P) |
| 135 | |
| 136 | npt.assert_almost_equal(ref_P, comp_P) |
| 137 | npt.assert_almost_equal(ref_I, comp_I) |
| 138 | npt.assert_almost_equal(ref_left_P, comp_left_P) |
| 139 | npt.assert_almost_equal(ref_left_I, comp_left_I) |