Skip to content

Commit 197b2b6

Browse files
committed
Make *Fit do not accept flat time series (#113)
* Fix #112 * Fix never-run tests
1 parent 4c51d2f commit 197b2b6

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

CHANGELOG.md

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

2727
### Fixed
2828

29-
--
29+
- **Breaking:** {Bazin,Villar}Fit requires variability now and do not accept flat time series anymore https://github.com/light-curve/light-curve-feature/issues/112 https://github.com/light-curve/light-curve-feature/pull/113
3030

3131
### Security
3232

src/features/bazin_fit.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ lazy_info!(
108108
t_required: true,
109109
m_required: true,
110110
w_required: true,
111-
sorting_required: true, // improve reproducibility
112-
variability_required: false,
111+
sorting_required: true, // improves reproducibility
112+
variability_required: true,
113113
);
114114

115115
struct Params<'a, T> {
@@ -419,13 +419,22 @@ mod tests {
419419
check_feature!(BazinFit);
420420

421421
feature_test!(
422-
bazin_fit_plateau,
422+
bazin_fit_almost_plateau,
423423
[BazinFit::default()],
424424
[0.0, 0.0, 10.0, 5.0, 5.0, 0.0], // initial model parameters and zero chi2
425425
linspace(0.0, 10.0, 11),
426-
[0.0; 11],
426+
linspace(0.0, 1e-100, 11), // make it a bit non-flat
427427
);
428428

429+
#[test]
430+
fn bazin_fit_plateau() {
431+
let fe = BazinFit::default();
432+
let t = linspace(0.0, 10.0, 11);
433+
let f = [0.0; 11];
434+
let mut ts = TimeSeries::new_without_weight(&t, &f);
435+
assert!(fe.eval(&mut ts).is_err());
436+
}
437+
429438
fn bazin_fit_noisy(eval: BazinFit) {
430439
const N: usize = 50;
431440

src/features/villar_fit.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ lazy_info!(
126126
t_required: true,
127127
m_required: true,
128128
w_required: true,
129-
sorting_required: true, // improve reproducibility
130-
variability_required: false,
129+
sorting_required: true, // improves reproducibility
130+
variability_required: true,
131131
);
132132

133133
impl<T, U> FitModelTrait<T, U, NPARAMS> for VillarFit
@@ -610,13 +610,22 @@ mod tests {
610610
check_feature!(VillarFit);
611611

612612
feature_test!(
613-
villar_fit_plateau,
613+
villar_fit_almost_plateau,
614614
[VillarFit::default()],
615615
[0.0, 0.0, 10.0, 5.0, 5.0, 0.0, 1.0, 0.0], // initial model parameters and zero chi2
616616
linspace(0.0, 10.0, 11),
617-
[0.0; 11],
617+
linspace(0.0, 1e-100, 11), // make it a bit non-flat
618618
);
619619

620+
#[test]
621+
fn villar_fit_plateau() {
622+
let fe = VillarFit::default();
623+
let t = linspace(0.0, 10.0, 11);
624+
let f = [0.0; 11];
625+
let mut ts = TimeSeries::new_without_weight(&t, &f);
626+
assert!(fe.eval(&mut ts).is_err());
627+
}
628+
620629
#[cfg(any(
621630
feature = "gsl",
622631
any(feature = "ceres-source", feature = "ceres-system")

0 commit comments

Comments
 (0)