From cb287089d824f8654cd59f8c2697e5f83ab33094 Mon Sep 17 00:00:00 2001 From: Pieter De Vis Date: Thu, 14 Aug 2025 14:35:14 +0100 Subject: [PATCH 1/3] bug fix trunctated gaussian --- .gitignore | 2 ++ comet_maths/_version.py | 2 +- comet_maths/generate_sample/generate_sample.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c12ed68..dcd344d 100644 --- a/.gitignore +++ b/.gitignore @@ -119,3 +119,5 @@ ENV/ # macOS temporary files .DS_Store +*.png +*.pdf diff --git a/comet_maths/_version.py b/comet_maths/_version.py index 9e604c0..e13bd59 100644 --- a/comet_maths/_version.py +++ b/comet_maths/_version.py @@ -1 +1 @@ -__version__ = "1.0.7" +__version__ = "1.0.8" diff --git a/comet_maths/generate_sample/generate_sample.py b/comet_maths/generate_sample/generate_sample.py index 92b1b21..b4936dc 100644 --- a/comet_maths/generate_sample/generate_sample.py +++ b/comet_maths/generate_sample/generate_sample.py @@ -512,21 +512,21 @@ def generate_sample_correlated( if len(corr_x[i]) == len(u_x[i].ravel()): # cov_x = cm.convert_corr_to_cov(corr_x[i], u_x[i]) MC_data = generate_sample_corr( - MCsteps, x[i], u_x[i], corr_x[i], dtype=dtype + MCsteps, x[i], u_x[i], corr_x[i], dtype=dtype, pdf_shape=pdf_shape, pdf_params=pdf_params ) elif len(corr_x[i]) == len(u_x[i]): MC_data = np.zeros((MCsteps,) + (u_x[i].shape)) for j in range(len(u_x[i][0])): # cov_x = cm.convert_corr_to_cov(corr_x[i], u_x[i][:, j]) MC_data[:, :, j] = generate_sample_corr( - MCsteps, x[i][:, j], u_x[i][:, j], corr_x[i], dtype=dtype + MCsteps, x[i][:, j], u_x[i][:, j], corr_x[i], dtype=dtype, pdf_shape=pdf_shape, pdf_params=pdf_params ) elif u_x[i].ndim > 1 and len(corr_x[i]) == len(u_x[i][0]): MC_data = np.zeros((MCsteps,) + (u_x[i].shape)) for j in range(len(u_x[i][:, 0])): # cov_x = cm.convert_corr_to_cov(corr_x[i], u_x[i][j]) MC_data[:, j, :] = generate_sample_corr( - MCsteps, x[i][j], u_x[i][j], corr_x[i], dtype=dtype + MCsteps, x[i][j], u_x[i][j], corr_x[i], dtype=dtype, pdf_shape=pdf_shape, pdf_params=pdf_params ) else: raise NotImplementedError( From f172d144729e09f391ca3c695e729802e0534c8f Mon Sep 17 00:00:00 2001 From: Pieter De Vis Date: Thu, 14 Aug 2025 14:36:55 +0100 Subject: [PATCH 2/3] black --- comet_maths/__init__.py | 1 + .../generate_sample/generate_sample.py | 25 ++++++++++++++++--- .../probability_density_function.py | 1 + comet_maths/interpolation/interpolation.py | 6 ++--- 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/comet_maths/__init__.py b/comet_maths/__init__.py index d7b0889..f7d655a 100644 --- a/comet_maths/__init__.py +++ b/comet_maths/__init__.py @@ -1,4 +1,5 @@ """comet_maths - Mathematical algorithms and tools to use within CoMet toolkit.""" + from comet_maths.generate_sample.generate_sample import ( generate_sample, generate_error_sample, diff --git a/comet_maths/generate_sample/generate_sample.py b/comet_maths/generate_sample/generate_sample.py index b4936dc..283cd04 100644 --- a/comet_maths/generate_sample/generate_sample.py +++ b/comet_maths/generate_sample/generate_sample.py @@ -1,4 +1,5 @@ """describe class""" + import copy import warnings @@ -512,21 +513,39 @@ def generate_sample_correlated( if len(corr_x[i]) == len(u_x[i].ravel()): # cov_x = cm.convert_corr_to_cov(corr_x[i], u_x[i]) MC_data = generate_sample_corr( - MCsteps, x[i], u_x[i], corr_x[i], dtype=dtype, pdf_shape=pdf_shape, pdf_params=pdf_params + MCsteps, + x[i], + u_x[i], + corr_x[i], + dtype=dtype, + pdf_shape=pdf_shape, + pdf_params=pdf_params, ) elif len(corr_x[i]) == len(u_x[i]): MC_data = np.zeros((MCsteps,) + (u_x[i].shape)) for j in range(len(u_x[i][0])): # cov_x = cm.convert_corr_to_cov(corr_x[i], u_x[i][:, j]) MC_data[:, :, j] = generate_sample_corr( - MCsteps, x[i][:, j], u_x[i][:, j], corr_x[i], dtype=dtype, pdf_shape=pdf_shape, pdf_params=pdf_params + MCsteps, + x[i][:, j], + u_x[i][:, j], + corr_x[i], + dtype=dtype, + pdf_shape=pdf_shape, + pdf_params=pdf_params, ) elif u_x[i].ndim > 1 and len(corr_x[i]) == len(u_x[i][0]): MC_data = np.zeros((MCsteps,) + (u_x[i].shape)) for j in range(len(u_x[i][:, 0])): # cov_x = cm.convert_corr_to_cov(corr_x[i], u_x[i][j]) MC_data[:, j, :] = generate_sample_corr( - MCsteps, x[i][j], u_x[i][j], corr_x[i], dtype=dtype, pdf_shape=pdf_shape, pdf_params=pdf_params + MCsteps, + x[i][j], + u_x[i][j], + corr_x[i], + dtype=dtype, + pdf_shape=pdf_shape, + pdf_params=pdf_params, ) else: raise NotImplementedError( diff --git a/comet_maths/generate_sample/probability_density_function.py b/comet_maths/generate_sample/probability_density_function.py index 6b8005d..66c6e75 100644 --- a/comet_maths/generate_sample/probability_density_function.py +++ b/comet_maths/generate_sample/probability_density_function.py @@ -1,4 +1,5 @@ """describe class""" + import warnings """___Built-In Modules___""" diff --git a/comet_maths/interpolation/interpolation.py b/comet_maths/interpolation/interpolation.py index 4f94b32..50b1e45 100644 --- a/comet_maths/interpolation/interpolation.py +++ b/comet_maths/interpolation/interpolation.py @@ -1,4 +1,4 @@ -""" Module for interpolation of data and enables propagation of uncertainties through the interpolation.""" +"""Module for interpolation of data and enables propagation of uncertainties through the interpolation.""" from typing import Union, Optional, List, Tuple @@ -108,9 +108,7 @@ def interpolate_1d_along_example( plot_residuals=self.plot_residuals, ) - def interpolate_1d( - self, x_i: np.ndarray, y_i: np.ndarray, x: np.ndarray - ) -> Union[ + def interpolate_1d(self, x_i: np.ndarray, y_i: np.ndarray, x: np.ndarray) -> Union[ np.ndarray, Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray, np.ndarray], From 180d7ee54e8ba3e120db49987dd1c738894d33c1 Mon Sep 17 00:00:00 2001 From: Pieter De Vis Date: Thu, 14 Aug 2025 14:49:17 +0100 Subject: [PATCH 3/3] black --- comet_maths/interpolation/interpolation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/comet_maths/interpolation/interpolation.py b/comet_maths/interpolation/interpolation.py index 50b1e45..a227f21 100644 --- a/comet_maths/interpolation/interpolation.py +++ b/comet_maths/interpolation/interpolation.py @@ -108,7 +108,9 @@ def interpolate_1d_along_example( plot_residuals=self.plot_residuals, ) - def interpolate_1d(self, x_i: np.ndarray, y_i: np.ndarray, x: np.ndarray) -> Union[ + def interpolate_1d( + self, x_i: np.ndarray, y_i: np.ndarray, x: np.ndarray + ) -> Union[ np.ndarray, Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray, np.ndarray],