From 6481aa14250346407fa37c1feecacd20c370eaa3 Mon Sep 17 00:00:00 2001 From: Richard R <58728519+rrjbca@users.noreply.github.com> Date: Tue, 13 Jul 2021 16:10:36 +0100 Subject: [PATCH 1/2] DOC: Inverse transform sampling accuracy warning --- skypy/galaxies/redshift.py | 6 ++++++ skypy/utils/random.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/skypy/galaxies/redshift.py b/skypy/galaxies/redshift.py index 19e0021e2..adc079450 100644 --- a/skypy/galaxies/redshift.py +++ b/skypy/galaxies/redshift.py @@ -216,6 +216,12 @@ def redshifts_from_comoving_density(redshift, density, sky_area, cosmology, nois If the `noise` parameter is set to true, the number of galaxies has Poisson noise. If `noise` is false, the expected number of galaxies is used. + .. warning:: + The inverse cumulative distribution function is approximated from the + number density and comoving volume calculated at the given `redshift` + values. The user must choose suitable `redshift` values to satisfy + their desired numerical accuracy. + Parameters ---------- redshift : array_like diff --git a/skypy/utils/random.py b/skypy/utils/random.py index 76ecde2bf..dcb69a6a6 100644 --- a/skypy/utils/random.py +++ b/skypy/utils/random.py @@ -21,6 +21,12 @@ def schechter(alpha, x_min, x_max, resolution=100, size=None, scale=1.): """Sample from the Schechter function. + .. warning:: + The inverse cumulative distribution function is approximated from the + Schechter function evaluated on a logarithmically-spaced grid. The user + must choose the `resolution` of this grid to satisfy their desired + numerical accuracy. + Parameters ---------- alpha : float or int From 194bf12b4ddf2c2949a41046c2fbc1d1de25c0f7 Mon Sep 17 00:00:00 2001 From: Richard R <58728519+rrjbca@users.noreply.github.com> Date: Tue, 13 Jul 2021 16:20:44 +0100 Subject: [PATCH 2/2] Numpy docstring format for warnings --- skypy/galaxies/redshift.py | 13 +++++++------ skypy/utils/random.py | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/skypy/galaxies/redshift.py b/skypy/galaxies/redshift.py index adc079450..f048a3574 100644 --- a/skypy/galaxies/redshift.py +++ b/skypy/galaxies/redshift.py @@ -216,12 +216,6 @@ def redshifts_from_comoving_density(redshift, density, sky_area, cosmology, nois If the `noise` parameter is set to true, the number of galaxies has Poisson noise. If `noise` is false, the expected number of galaxies is used. - .. warning:: - The inverse cumulative distribution function is approximated from the - number density and comoving volume calculated at the given `redshift` - values. The user must choose suitable `redshift` values to satisfy - their desired numerical accuracy. - Parameters ---------- redshift : array_like @@ -241,6 +235,13 @@ def redshifts_from_comoving_density(redshift, density, sky_area, cosmology, nois Sampled redshifts such that the comoving number density of galaxies corresponds to the input distribution. + Warnings + -------- + The inverse cumulative distribution function is approximated from the + number density and comoving volume calculated at the given `redshift` + values. The user must choose suitable `redshift` values to satisfy their + desired numerical accuracy. + ''' # redshift number density diff --git a/skypy/utils/random.py b/skypy/utils/random.py index dcb69a6a6..c301eeec0 100644 --- a/skypy/utils/random.py +++ b/skypy/utils/random.py @@ -21,12 +21,6 @@ def schechter(alpha, x_min, x_max, resolution=100, size=None, scale=1.): """Sample from the Schechter function. - .. warning:: - The inverse cumulative distribution function is approximated from the - Schechter function evaluated on a logarithmically-spaced grid. The user - must choose the `resolution` of this grid to satisfy their desired - numerical accuracy. - Parameters ---------- alpha : float or int @@ -47,6 +41,13 @@ def schechter(alpha, x_min, x_max, resolution=100, size=None, scale=1.): x_sample : array_like Samples drawn from the Schechter function. + Warnings + -------- + The inverse cumulative distribution function is approximated from the + Schechter function evaluated on a logarithmically-spaced grid. The user + must choose the `resolution` of this grid to satisfy their desired + numerical accuracy. + References ---------- .. [1] https://en.wikipedia.org/wiki/Luminosity_function_(astronomy)