Skip to content

Commit

Permalink
testing improved for empricial_cdf
Browse files Browse the repository at this point in the history
  • Loading branch information
aronsho committed Jul 3, 2024
1 parent 7b19cc5 commit 315f57d
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions seismostats/analysis/tests/test_estimate_mc.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,21 @@ def test_empirical_cdf(setup_magnitudes, delta_m=0.1):
# 1. with equal weights
magnitudes = np.array([0.5, 0.6, 0.7, 0.8, 0.9])
weights = np.array([1, 1, 1, 1, 1])
x, y = empirical_cdf(magnitudes, mc=0, delta_m=0.1, weights=weights)
assert_almost_equal(x, np.arange(0, 1, 0.1))
assert_almost_equal(y, [0, 0, 0, 0, 0, 0.2, 0.4, 0.6, 0.8, 1])
x_weight, y_weight = empirical_cdf(
magnitudes, mc=0, delta_m=0.1, weights=weights)
x, y = empirical_cdf(magnitudes, mc=0, delta_m=0.1)
assert_almost_equal(x_weight, np.arange(0, 1, 0.1))
assert_almost_equal(y_weight, [0, 0, 0, 0, 0, 0.2, 0.4, 0.6, 0.8, 1])
assert_almost_equal(x_weight, x)
assert_almost_equal(y_weight, y)

# 2. with different weights
magnitudes = np.array([0.5, 0.6, 0.7, 0.8, 0.9])
weights = np.array([0.5, 0.5, 0.5, 0.5, 3])
x, y = empirical_cdf(magnitudes, mc=0, delta_m=0.1, weights=weights)
assert_almost_equal(x, np.arange(0, 1, 0.1))
assert_almost_equal(y, [0, 0, 0, 0, 0, 0.1, 0.2, 0.3, 0.4, 1])
x_weight, y_weight = empirical_cdf(
magnitudes, mc=0, delta_m=0.1, weights=weights)
assert_almost_equal(x_weight, np.arange(0, 1, 0.1))
assert_almost_equal(y_weight, [0, 0, 0, 0, 0, 0.1, 0.2, 0.3, 0.4, 1])


@pytest.fixture
Expand Down

0 comments on commit 315f57d

Please sign in to comment.