Ejemplo n.º 1
0
    def test_get_model(self):
        """Test model getter function."""
        for model_name in MODEL_DATA:
            model = models.get_isotherm_model(model_name)
            assert model.name == model_name

        with pytest.raises(ParameterError):
            models.get_isotherm_model('bad_model')
Ejemplo n.º 2
0
    def test_models_default_guess(self, m_name):
        """Test each model's default guess function."""

        model = models.get_isotherm_model(m_name)
        exp_guess = MODEL_DATA[m_name]['initial_guess']
        def_guess = model.initial_guess(1, 1)
        for param in def_guess:
            assert numpy.isclose(exp_guess[param], def_guess[param], 0.01)
Ejemplo n.º 3
0
    def test_models_s_pressure(self, m_name):
        """Test each model's spreading pressure function."""

        model = models.get_isotherm_model(m_name)
        model.params = MODEL_DATA[m_name]['test_parameters']
        test_values = MODEL_DATA[m_name]['test_values']

        for i, p in enumerate(test_values['pressure']):
            assert numpy.isclose(model.spreading_pressure(p),
                                 test_values['spreading_pressure'][i], 0.001)
Ejemplo n.º 4
0
    def test_models_fit_function(self, m_name):

        model = models.get_isotherm_model(m_name)
        test_values = MODEL_DATA[m_name]['test_values']
        param_guess = model.initial_guess(
            numpy.array(test_values['pressure']),
            numpy.array(test_values['loading']),
        )
        # param_real = MODEL_DATA[m_name]['test_parameters']

        model.fit(
            numpy.array(test_values['pressure']),
            numpy.array(test_values['loading']),
            param_guess,
            optimization_params=dict(max_nfev=1e6),
            verbose=True,
        )