From a348154f3df46aa8a45b4a0bc56302f37a63eae2 Mon Sep 17 00:00:00 2001 From: Daniel Morcuende Date: Mon, 27 Nov 2023 10:34:57 +0100 Subject: [PATCH 1/3] Correct typos in docstrings --- pyirf/interpolation/component_estimators.py | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/pyirf/interpolation/component_estimators.py b/pyirf/interpolation/component_estimators.py index 1d102d933..a948ee4eb 100644 --- a/pyirf/interpolation/component_estimators.py +++ b/pyirf/interpolation/component_estimators.py @@ -30,8 +30,8 @@ class BaseComponentEstimator: """ Base class for all Estimators working on specific IRF components. - While usable, it is encuraged to use the actual class for the respective IRF - component as it ensures further checks and if nessecarry e.g. unit handling. + While usable, it is encouraged to use the actual class for the respective IRF + component as it ensures further checks and if necessary e.g. unit handling. """ def __init__(self, grid_points): @@ -81,7 +81,7 @@ def __init__(self, grid_points): self.triangulation = Delaunay(self.grid_points) def _target_in_grid(self, target_point): - """Check wether target_point lies within grids convex hull, uses + """Check whether target_point lies within grids convex hull, uses simple comparison for 1D and Delaunay triangulation for >1D.""" if self.grid_dim == 1: return (target_point >= self.grid_points.min()) and ( @@ -128,7 +128,7 @@ def __call__(self, target_point): if target_point.shape[1] != self.grid_dim: raise ValueError( - "Missmatch between target-point and grid dimension." + "Mismatch between target-point and grid dimension." f" Grid has dimension {self.grid_dim}, target has dimension" f" {target_point.shape[1]}." ) @@ -148,8 +148,8 @@ class DiscretePDFComponentEstimator(BaseComponentEstimator): """ Base class for all Estimators working on IRF components that represent discretized PDFs. - While usable, it is encuraged to use the actual class for the respective IRF - component as it ensures further checks and if nessecarry e.g. unit handling. + While usable, it is encouraged to use the actual class for the respective IRF + component as it ensures further checks and if necessary e.g. unit handling. """ def __init__( @@ -175,7 +175,7 @@ def __init__( binned_pdf: np.ndarray, shape=(n_points, ..., n_bins) Discretized PDFs for all grid points and arbitrary further dimensions (in IRF term e.g. field-of-view offset bins). Actual interpolation dimension, - meaning the dimensions that contains actual histograms, has to be along + meaning the dimensions that contain actual histograms, have to be along the last axis. interpolator_cls: pyirf interpolator class, defaults to QuantileInterpolator. @@ -195,7 +195,7 @@ def __init__( TypeError: When bin_edges is not a np.ndarray. TypeError: - When binned_pdf is not a np.ndarray.. + When binned_pdf is not a np.ndarray. TypeError: When interpolator_cls is not a DiscretePDFInterpolator subclass. TypeError: @@ -271,8 +271,8 @@ class ParametrizedComponentEstimator(BaseComponentEstimator): Base class for all Estimators working on IRF components that represent parametrized or scalar quantities. - While usable, it is encuraged to use the actual class for the respective IRF - component as it ensures further checks and if nessecarry e.g. unit handling. + While usable, it is encouraged to use the actual class for the respective IRF + component as it ensures further checks and if necessary e.g. unit handling. """ def __init__( @@ -294,7 +294,7 @@ def __init__( Grid points at which interpolation templates exist params: np.ndarray, shape=(n_points, ..., n_params) Corresponding parameter values at each point in grid_points. - First dimesion has to correspond to number of grid_points. + First dimension has to correspond to the number of grid_points. interpolator_cls: pyirf interpolator class, defaults to GridDataInterpolator. interpolator_kwargs: dict @@ -317,7 +317,7 @@ def __init__( TypeError: When params is not a np.ndarray. ValueError: - When number of points grid_points and params is not matching. + When number of points grid_points and params do not match. Note ---- @@ -332,7 +332,7 @@ def __init__( raise TypeError("Input params is not a numpy array.") elif self.n_points != params.shape[0]: raise ValueError( - "Shape missmatch, number of grid_points and rows in params not matching." + "Shape mismatch, number of grid_points and rows in params not matching." ) # Make sure that 1D input is sorted in increasing order @@ -411,7 +411,7 @@ def __init__( None which is the same as passing an empty dict. min_effective_area: astropy.units.Quantity[area] Minimum value of effective area to be considered for interpolation. Values - lower then this value are set to this value. Defaults to 1 m**2. + lower than this value are set to this value. Defaults to 1 m**2. Note From bca3f5e80d089fc52c79368d17d7e4b33c9d4916 Mon Sep 17 00:00:00 2001 From: morcuended Date: Mon, 27 Nov 2023 10:48:12 +0000 Subject: [PATCH 2/3] correct typo in raised error messages --- pyirf/interpolation/component_estimators.py | 4 ++-- .../tests/test_component_estimator_base_classes.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyirf/interpolation/component_estimators.py b/pyirf/interpolation/component_estimators.py index a948ee4eb..5387a82ff 100644 --- a/pyirf/interpolation/component_estimators.py +++ b/pyirf/interpolation/component_estimators.py @@ -220,7 +220,7 @@ def __init__( raise TypeError("Input binned_pdf is not a numpy array.") elif self.n_points != binned_pdf.shape[0]: raise ValueError( - f"Shape missmatch, number of grid_points ({self.n_points}) and " + f"Shape mismatch, number of grid_points ({self.n_points}) and " f"number of histograms in binned_pdf ({binned_pdf.shape[0]}) " "not matching." ) @@ -228,7 +228,7 @@ def __init__( raise TypeError("Input bin_edges is not a numpy array.") elif binned_pdf.shape[-1] != (bin_edges.shape[0] - 1): raise ValueError( - f"Shape missmatch, bin_edges ({bin_edges.shape[0] - 1} bins) " + f"Shape mismatch, bin_edges ({bin_edges.shape[0] - 1} bins) " f"and binned_pdf ({binned_pdf.shape[-1]} bins) not matching." ) diff --git a/pyirf/interpolation/tests/test_component_estimator_base_classes.py b/pyirf/interpolation/tests/test_component_estimator_base_classes.py index 816c2ed35..dcfe24e98 100644 --- a/pyirf/interpolation/tests/test_component_estimator_base_classes.py +++ b/pyirf/interpolation/tests/test_component_estimator_base_classes.py @@ -88,7 +88,7 @@ def __init__(self, grid_points): interp(target2D_twopoints) with pytest.raises( - ValueError, match="Missmatch between target-point and grid dimension." + ValueError, match="Mismatch between target-point and grid dimension." ): interp = DummyEstimator(grid_points2D_good) interp(target1D_inGrid) @@ -163,7 +163,7 @@ def extrapolate(self, target_point): grid_points = np.array([1, 2, 3]) params_good = np.array([[1], [2], [3]]) - params_shape_missmatch = np.array([[1], [2]]) + params_shape_mismatch = np.array([[1], [2]]) with pytest.raises( TypeError, @@ -184,11 +184,11 @@ def extrapolate(self, target_point): with pytest.raises( ValueError, - match="Shape missmatch, number of grid_points and rows in params not matching.", + match="Shape mismatch, number of grid_points and rows in params not matching.", ): ParametrizedComponentEstimator( grid_points=grid_points, - params=params_shape_missmatch, + params=params_shape_mismatch, interpolator_cls=DummyInterpolator, ) @@ -276,7 +276,7 @@ def extrapolate(self, target_point): with pytest.raises( ValueError, match=re.escape( - "Shape missmatch, number of grid_points (3) and " + "Shape mismatch, number of grid_points (3) and " "number of histograms in binned_pdf (2) not matching." ), ): @@ -290,7 +290,7 @@ def extrapolate(self, target_point): with pytest.raises( ValueError, match=re.escape( - "Shape missmatch, bin_edges (10 bins) " + "Shape mismatch, bin_edges (10 bins) " "and binned_pdf (11 bins) not matching." ), ): From 9f3bd22ae096b3d7a73a0d134e653de76a77b7aa Mon Sep 17 00:00:00 2001 From: morcuended Date: Mon, 27 Nov 2023 10:56:26 +0000 Subject: [PATCH 3/3] Change default interp class in docsting for PSF and EDISP --- pyirf/interpolation/component_estimators.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyirf/interpolation/component_estimators.py b/pyirf/interpolation/component_estimators.py index 5387a82ff..740180e60 100644 --- a/pyirf/interpolation/component_estimators.py +++ b/pyirf/interpolation/component_estimators.py @@ -576,7 +576,7 @@ def __init__( or e.g. missing a fov_offset axis, the axis containing n_migration_bins has to be specified through axis. interpolator_cls: - pyirf interpolator class, defaults to GridDataInterpolator. + pyirf interpolator class, defaults to QuantileInterpolator. interpolator_kwargs: dict Dict of all kwargs that are passed to the interpolator, defaults to None which is the same as passing an empty dict. @@ -662,7 +662,7 @@ def __init__( This is assumed as default. If these axes are in different order the axis containing n_source_offset_bins has to be specified through axis. interpolator_cls: - pyirf interpolator class, defaults to GridDataInterpolator. + pyirf interpolator class, defaults to QuantileInterpolator. interpolator_kwargs: dict Dict of all kwargs that are passed to the interpolator, defaults to None which is the same as passing an empty dict.