def test_calculate_residuals(models): # pylint: disable=W0621 """Test calculate.calculate_residuals.""" for i_model, model in enumerate(models): print(f"Model {i_model}") (measurement_df, observable_df, parameter_df, simulation_df, expected_residuals, _, _) = model residual_dfs = calculate_residuals(measurement_df, simulation_df, observable_df, parameter_df) assert set( residual_dfs[0][RESIDUAL]) == pytest.approx(expected_residuals)
def test_calculate_non_normalized_residuals(models): # pylint: disable=W0621 """Test calculate.calculate_residuals without normalization.""" for i_model, model in enumerate(models): print(f"Model {i_model}") (measurement_df, observable_df, parameter_df, simulation_df, _, expected_residuals_nonorm, _) = model residual_dfs = calculate_residuals(measurement_df, simulation_df, observable_df, parameter_df, normalize=False) assert sorted(residual_dfs[0][RESIDUAL]) == \ pytest.approx(sorted(expected_residuals_nonorm))
def petab_residuals(pp, sim): """Computes the residuals based on the simulation data frame :param pp: petab problem :type pp: petab.Problem :param sim: simulation data frame :type sim: pd.DataFrame :return: the residuals as calculated by petab """ return petab.calculate_residuals(pp.measurement_df, sim, pp.observable_df, pp.parameter_df)