Skip to content

Commit e7f8cd9

Browse files
committed
Periodogram benchmarks vs scipy
1 parent 5841216 commit e7f8cd9

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12-
- Periodogram(freqs: ArrayLike | None = None) is added to set fixed user-defined frequency grids
12+
- Periodogram(freqs: ArrayLike | None = None) is added to set fixed user-defined frequency
13+
grids https://github.com/light-curve/light-curve-python/pull/528
1314

1415
### Changed
1516

light-curve/tests/light_curve_ext/test_periodogram.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,42 @@ def test_vs_lombscargle():
2727
assert_allclose(scipy_power, licu_power)
2828

2929

30+
@pytest.mark.parametrize(
31+
"grid_name, freqs",
32+
[("np.linspace", np.linspace(1.0, 100.0, 100_000)), ("np.geomspace", np.geomspace(1.0, 100.0, 100_000))],
33+
)
34+
def test_benchmark_periodogram_rust(benchmark, grid_name, freqs):
35+
benchmark.group = f"periodogram_freqs={grid_name}"
36+
benchmark.name = "rust"
37+
38+
rng = np.random.default_rng(0)
39+
n = 100
40+
41+
t = np.sort(rng.normal(0, 1, n))
42+
m = np.sin(12.3 * t) + 0.2 * rng.normal(0, 1, n)
43+
44+
fe = Periodogram(freqs=freqs, fast=False)
45+
benchmark(fe.freq_power, t, m)
46+
47+
48+
@pytest.mark.parametrize(
49+
"grid_name, freqs",
50+
[("np.linspace", np.linspace(1.0, 100.0, 100_000)), ("np.geomspace", np.geomspace(1.0, 100.0, 100_000))],
51+
)
52+
def test_benchmark_periodogram_scipy(benchmark, grid_name, freqs):
53+
benchmark.group = f"periodogram_freqs={grid_name}"
54+
benchmark.name = "scipy"
55+
56+
rng = np.random.default_rng(0)
57+
n = 100
58+
59+
t = np.sort(rng.normal(0, 1, n))
60+
m = np.sin(12.3 * t) + 0.2 * rng.normal(0, 1, n)
61+
y = (m - m.mean()) / m.std(ddof=1)
62+
63+
benchmark(lombscargle, t, y, freqs, precenter=True, normalize=False)
64+
65+
3066
def test_different_freq_grids():
3167
rng = np.random.default_rng(None)
3268

0 commit comments

Comments
 (0)