MCPcopy Create free account
hub / github.com/Open-Quant/openquant / test_value_error_raise

Function test_value_error_raise

crates/openquant/tests/sb_bagging.rs:116–162  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

114 assert_eq!(sb.estimators_samples.len(), first_len);
115
116 sb.n_estimators += 2;
117 sb.fit(&x, &y, &ind, Some(&weights)).unwrap();
118 assert!(sb.estimators_samples.len() >= first_len + 2);
119}
120
121#[test]
122fn test_value_error_raise() {
123 let (x, y, _, ind) = synthetic_dataset();
124 let w = vec![1.0; x.nrows()];
125
126 let mut bagging_1 = SequentiallyBootstrappedBaggingClassifier::new(1);
127 bagging_1.supports_sample_weight = false;
128 assert_eq!(
129 bagging_1.fit(&x, &y, &ind, Some(&w)).unwrap_err(),
130 SbBaggingError::SampleWeightNotSupported
131 );
132
133 let mut bagging_2 = SequentiallyBootstrappedBaggingClassifier::new(1);
134 bagging_2.max_samples = MaxSamples::Int(2_000_000);
135 assert_eq!(
136 bagging_2.fit(&x, &y, &ind, Some(&w)).unwrap_err(),
137 SbBaggingError::MaxSamplesOutOfRange
138 );
139
140 let mut bagging_4 = SequentiallyBootstrappedBaggingClassifier::new(1);
141 bagging_4.max_features = MaxFeatures::Int(2_000_000);
142 assert_eq!(
143 bagging_4.fit(&x, &y, &ind, Some(&w)).unwrap_err(),
144 SbBaggingError::MaxFeaturesOutOfRange
145 );
146
147 let mut bagging_5 = SequentiallyBootstrappedBaggingClassifier::new(1);
148 bagging_5.oob_score = true;
149 bagging_5.warm_start = true;
150 assert_eq!(
151 bagging_5.fit(&x, &y, &ind, Some(&w)).unwrap_err(),
152 SbBaggingError::WarmStartWithOob
153 );
154
155 let mut bagging_6 = SequentiallyBootstrappedBaggingClassifier::new(1);
156 bagging_6.warm_start = true;
157 bagging_6.n_estimators = 3;
158 bagging_6.fit(&x, &y, &ind, None).unwrap();
159 bagging_6.n_estimators = 1;
160 assert_eq!(
161 bagging_6.fit(&x, &y, &ind, None).unwrap_err(),
162 SbBaggingError::DecreasingEstimators
163 );
164
165 let mut bagging_7 = SequentiallyBootstrappedBaggingClassifier::new(1);

Callers

nothing calls this directly

Calls 2

synthetic_datasetFunction · 0.85
fitMethod · 0.45

Tested by

no test coverage detected