Skip to content

Documentation to have climada 6 work in Euler - #1103

Closed
spjuhel wants to merge 1 commit into
developfrom
feature/euler_with_spack
Closed

Documentation to have climada 6 work in Euler#1103
spjuhel wants to merge 1 commit into
developfrom
feature/euler_with_spack

adds guide for using climada with spack on euler

fb904ea
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
GitHub Actions / Core / Unit Test Results (3.10) failed Nov 3, 2025 in 0s

1 fail, 735 pass in 4m 47s

  1 files    1 suites   4m 47s ⏱️
736 tests 735 ✅ 0 💤 1 ❌
745 runs  744 ✅ 0 💤 1 ❌

Results for commit fb904ea.

Annotations

Check warning on line 0 in climada.engine.unsequa.test.test_unsequa.TestCalcImpact

See this annotation in the file changed.

@github-actions github-actions / Core / Unit Test Results (3.10)

test_calc_sensitivity_all_pass (climada.engine.unsequa.test.test_unsequa.TestCalcImpact) failed

tests_xml/tests.xml [took 46s]
Raw output
AssertionError: 0.004658 != np.float64(0.00464902644639644) within 5 places (np.float64(8.97355360355949e-06) difference)
self = <climada.engine.unsequa.test.test_unsequa.TestCalcImpact testMethod=test_calc_sensitivity_all_pass>

    def test_calc_sensitivity_all_pass(self):
        """Test compute sensitivity using all different sensitivity methods"""
    
        # define input_vars
        exp_unc, impf_unc, haz_unc = make_input_vars()
    
        # dict to store the parameters and expected results for the tests
        test_dict = {
            "pawn": {
                "sampling_method": "saltelli",
                "sampling_kwargs": {},
                "N": 4,
                "sensitivity_kwargs": {"S": 10, "seed": 12345},
                "test_param_name": ["x_exp", 0],
                "test_si_name": ["CV", 16],
                "test_si_value": [0.25000, 2],
            },
            "hdmr": {
                "sampling_method": "saltelli",
                "sampling_kwargs": {},
                "N": 100,
                "sensitivity_kwargs": {},
                "test_param_name": ["x_exp", 2],
                "test_si_name": ["Sa", 4],
                "test_si_value": [0.004658, 3],
            },
            "ff": {
                "sampling_method": "ff",
                "sampling_kwargs": {"seed": 12345},
                "N": 4,
                "sensitivity_kwargs": {"second_order": True},
                "test_param_name": ["x_exp", 0],
                "test_si_name": ["IE", 4],
                "test_si_value": [865181825.901295, 10],
            },
            "sobol": {
                "sampling_method": "saltelli",
                "sampling_kwargs": {},
                "N": 4,
                "sensitivity_kwargs": {},
                "test_param_name": ["x_paa", 5],
                "test_si_name": ["ST", 8],
                "test_si_value": [0.313025, 10],
            },
            "dgsm": {
                "sampling_method": "finite_diff",
                "N": 4,
                "sampling_kwargs": {"seed": 12345},
                "sensitivity_kwargs": {
                    "num_resamples": 100,
                    "conf_level": 0.95,
                    "seed": 12345,
                },
                "test_param_name": ["x_exp", 0],
                "test_si_name": ["dgsm", 8],
                "test_si_value": [1.697516e-01, 9],
            },
            "fast": {
                "sampling_method": "fast_sampler",
                "sampling_kwargs": {"M": 4, "seed": 12345},
                "N": 256,
                "sensitivity_kwargs": {"M": 4, "seed": 12345},
                "test_param_name": ["x_exp", 0],
                "test_si_name": ["S1_conf", 8],
                "test_si_value": [0.671396, 1],
            },
            "rbd_fast": {
                "sampling_method": "saltelli",
                "sampling_kwargs": {},
                "N": 24,
                "sensitivity_kwargs": {"M": 4, "seed": 12345},
                "test_param_name": ["x_exp", 0],
                "test_si_name": ["S1_conf", 4],
                "test_si_value": [0.152609, 4],
            },
            "morris": {
                "sampling_method": "morris",
                "sampling_kwargs": {"seed": 12345},
                "N": 4,
                "sensitivity_kwargs": {},
                "test_param_name": ["x_exp", 0],
                "test_si_name": ["mu", 1],
                "test_si_value": [5066460029.63911, 8],
            },
        }
    
        def test_sensitivity_method(
            exp_unc, impf_unc, haz_unc, sensitivity_method, param_dict, places
        ):
            """Function to test each seaprate sensitivity method"""
            unc_calc = CalcImpact(exp_unc, impf_unc, haz_unc)
            unc_data = unc_calc.make_sample(
                N=param_dict["N"],
                sampling_method=param_dict["sampling_method"],
                sampling_kwargs=param_dict["sampling_kwargs"],
            )
            unc_data = unc_calc.uncertainty(
                unc_data, calc_eai_exp=False, calc_at_event=False
            )
    
            # Call the sensitivity method with each method's specific arguments
            unc_data = unc_calc.sensitivity(
                unc_data,
                sensitivity_method=sensitivity_method,
                sensitivity_kwargs=param_dict["sensitivity_kwargs"],
            )
    
            self.assertEqual(
                param_dict["test_param_name"][0],
                unc_data.aai_agg_sens_df["param"][param_dict["test_param_name"][1]],
            )
            self.assertEqual(
                param_dict["test_si_name"][0],
                unc_data.aai_agg_sens_df["si"][param_dict["test_si_name"][1]],
            )
            self.assertAlmostEqual(
                param_dict["test_si_value"][0],
                unc_data.aai_agg_sens_df["aai_agg"][param_dict["test_si_value"][1]],
                places=places,
            )
    
            self.assertEqual(unc_data.aai_agg_unc_df.size, unc_data.n_samples)
    
            self.assertEqual(
                unc_data.freq_curve_unc_df.size, unc_data.n_samples * len(unc_calc.rp)
            )
            self.assertTrue(unc_data.eai_exp_unc_df.empty)
            self.assertTrue(unc_data.at_event_unc_df.empty)
    
        # loop over each method and do test
        for sensitivity_method, method_params in test_dict.items():
>           test_sensitivity_method(
                exp_unc,
                impf_unc,
                haz_unc,
                sensitivity_method,
                method_params,
                places=2 if sensitivity_method == "rbd_fast" else 5,
            )

climada/engine/unsequa/test/test_unsequa.py:697: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
climada/engine/unsequa/test/test_unsequa.py:681: in test_sensitivity_method
    self.assertAlmostEqual(
E   AssertionError: 0.004658 != np.float64(0.00464902644639644) within 5 places (np.float64(8.97355360355949e-06) difference)