From 95b6bd23d7d28c4aedb7d3624b6619ec847e0c1f Mon Sep 17 00:00:00 2001 From: Simon Chabot Date: Mon, 1 Jun 2026 14:33:02 +0200 Subject: [PATCH 1/4] ci: remove python 3.14 from the matrix test as resourcecode is not yet compatible with python3.14 (because of pyiodide compatiblities) --- .github/workflows/check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 1fe7fc5..50f4c73 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -41,7 +41,6 @@ jobs: fail-fast: false matrix: py: - - "3.14" - "3.13" - "3.12" - "3.11" From 8d5d6f428292abb5d0f9d68314ffc8d3afe7f642 Mon Sep 17 00:00:00 2001 From: Simon Chabot Date: Mon, 1 Jun 2026 15:30:38 +0200 Subject: [PATCH 2/4] fix: correct covariance matrix handling in Nataf copula functions - Fix censgaussfit to construct proper 2x2 covariance matrix in 2D case instead of incorrectly assigning 1D array to sigma - Fix run_simulation to access correlation coefficient as rho[0] instead of rho for 2D case Resolves errors: - numpy.linalg.LinAlgError: 1-dimensional array given - ValueError: cannot reshape array of size 4 into shape (1,1) - ValueError: setting an array element with a sequence --- doc/sg_execution_times.rst | 14 +++++++------- resourcecode/eva/censgaussfit.py | 9 ++++++--- resourcecode/eva/simulation.py | 4 ++-- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/doc/sg_execution_times.rst b/doc/sg_execution_times.rst index e5ef5cc..a747ab3 100644 --- a/doc/sg_execution_times.rst +++ b/doc/sg_execution_times.rst @@ -6,7 +6,7 @@ Computation times ================= -**00:10.513** total execution time for 5 files **from all galleries**: +**00:26.067** total execution time for 5 files **from all galleries**: .. container:: @@ -32,18 +32,18 @@ Computation times * - Example - Time - Mem (MB) - * - :ref:`sphx_glr_auto_examples_plot_4_Producible.py` (``..\examples\plot_4_Producible.py``) - - 00:10.513 + * - :ref:`sphx_glr_auto_examples_plot_2_Multivariate_Extremes.py` (``../examples/plot_2_Multivariate_Extremes.py``) + - 00:26.067 - 0.0 - * - :ref:`sphx_glr_auto_examples_plot_0_Database_exploration.py` (``..\examples\plot_0_Database_exploration.py``) + * - :ref:`sphx_glr_auto_examples_plot_0_Database_exploration.py` (``../examples/plot_0_Database_exploration.py``) - 00:00.000 - 0.0 - * - :ref:`sphx_glr_auto_examples_plot_1_data_extraction.py` (``..\examples\plot_1_data_extraction.py``) + * - :ref:`sphx_glr_auto_examples_plot_1_data_extraction.py` (``../examples/plot_1_data_extraction.py``) - 00:00.000 - 0.0 - * - :ref:`sphx_glr_auto_examples_plot_2_Multivariate_Extremes.py` (``..\examples\plot_2_Multivariate_Extremes.py``) + * - :ref:`sphx_glr_auto_examples_plot_3_Operation_Planning.py` (``../examples/plot_3_Operation_Planning.py``) - 00:00.000 - 0.0 - * - :ref:`sphx_glr_auto_examples_plot_3_Operation_Planning.py` (``..\examples\plot_3_Operation_Planning.py``) + * - :ref:`sphx_glr_auto_examples_plot_4_Producible.py` (``../examples/plot_4_Producible.py``) - 00:00.000 - 0.0 diff --git a/resourcecode/eva/censgaussfit.py b/resourcecode/eva/censgaussfit.py index f107687..62a5fb0 100644 --- a/resourcecode/eva/censgaussfit.py +++ b/resourcecode/eva/censgaussfit.py @@ -54,6 +54,7 @@ def censgaussfit(data: np.ndarray, q: float) -> OptimizeResult: tail_dependency_obs = sum(mask) / data.shape[0] th_norm = norm.ppf(q) + n_vars = data.shape[1] def fitness(cov): # For the 2D case, we have only one parameter @@ -62,7 +63,9 @@ def fitness(cov): set_trig(sigma, cov, "upper") set_trig(sigma, cov, "lower") else: - sigma = cov + sigma = np.eye(2) + sigma[0, 1] = cov[0] + sigma[1, 0] = cov[0] # Check if sigma is positive semi-definite eigenvalues = np.linalg.eigvalsh(sigma) @@ -70,8 +73,8 @@ def fitness(cov): # Return a large penalty for non-PSD matrices return 1e10 - rv = multivariate_normal(mean=np.zeros(len(cov)), cov=sigma, allow_singular=True) - upper_point = np.full(len(cov), th_norm) + rv = multivariate_normal(mean=np.zeros(n_vars), cov=sigma, allow_singular=True) + upper_point = np.full(n_vars, th_norm) prob = 1 - rv.cdf(upper_point) return (tail_dependency_obs - prob) ** 2 diff --git a/resourcecode/eva/simulation.py b/resourcecode/eva/simulation.py index 602e1f0..d2a1482 100644 --- a/resourcecode/eva/simulation.py +++ b/resourcecode/eva/simulation.py @@ -64,8 +64,8 @@ def run_simulation( set_trig(sigma, rho, "lower") else: sigma = np.eye(2) - sigma[1, 0] = rho - sigma[0, 1] = rho + sigma[1, 0] = rho[0] + sigma[0, 1] = rho[0] result = None while result is None or len(result) < n_simulations: From eea970e321047577fe3770d8a3ce6ae8f785a977 Mon Sep 17 00:00:00 2001 From: Simon Chabot Date: Mon, 1 Jun 2026 15:34:16 +0200 Subject: [PATCH 3/4] ci: remove superflous extra doc --- .github/workflows/documentation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 14a64d1..7ce9e6f 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -35,7 +35,7 @@ jobs: version: "0.11.16" enable-cache: true - name: Install the project - run: uv sync --locked --all-extras --extra doc + run: uv sync --locked --all-extras - name: Sphinx build run: uv run sphinx-build doc _build - name: Deploy From ca71a31535b0350ca3a18cdf76da7f207ac47e12 Mon Sep 17 00:00:00 2001 From: Simon Chabot Date: Mon, 1 Jun 2026 15:50:13 +0200 Subject: [PATCH 4/4] ci: no token needed from github to test.pypi.org --- .github/workflows/publish-to-pypi.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index d6df6c7..b71be67 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -119,4 +119,4 @@ jobs: with: version: "0.11.16" - name: Publish Resourcecode 📦 to TestPyPI - run: uv publish --token ${{ secrets.TEST_PYPI_TOKEN }} --publish-url https://test.pypi.org/legacy/ + run: uv publish --publish-url https://test.pypi.org/legacy/