def test_default_seed_is_zero(self):
        n_models = 2
        n_features = 3

        cepstral1 = VarianceRegressor(n_models=n_models, n_features=n_features)
        cepstral2 = VarianceRegressor(n_models=n_models,
                                      n_features=n_features,
                                      rng=0)
        np.testing.assert_allclose(cepstral1.prediction_error.weights_,
                                   cepstral2.prediction_error.weights_)
    def test_rng_can_be_seed(self):
        n_models = 2
        n_features = 3
        seed = 43

        cepstral1 = VarianceRegressor(n_models=n_models,
                                      n_features=n_features,
                                      rng=seed)
        cepstral2 = VarianceRegressor(
            n_models=n_models,
            n_features=n_features,
            rng=np.random.default_rng(seed),
        )
        np.testing.assert_allclose(cepstral1.prediction_error.weights_,
                                   cepstral2.prediction_error.weights_)
    def setUp(self):
        self.n_models = 3
        self.n_features = 4
        self.order = 3
        self.rng = np.random.default_rng(1)
        self.weights = self.rng.normal(size=(self.n_models, self.n_features))

        self.variance = VarianceRegressor(self.weights)
    def test_weights_initialized_using_rng_normal(self):
        n_models = 2
        n_features = 3

        rng = mock.Mock()
        weights = np.reshape(np.arange(n_models * n_features),
                             (n_models, n_features))
        rng.normal = mock.Mock(return_value=weights)

        cepstral = VarianceRegressor(n_models=n_models,
                                     n_features=n_features,
                                     rng=rng)
        np.testing.assert_allclose(cepstral.prediction_error.weights_, weights)
 def test_raises_if_n_features_does_not_match_weights_size(self):
     with self.assertRaises(ValueError):
         VarianceRegressor(n_features=2, weights=np.zeros((3, 4)))