Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/about/photometry_overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ Here:
- :math:`\alpha` is the faint-end slope,
- :math:`x` is the luminosity ratio :math:`L/L_\star` written in magnitude form.

The parameter :math:`M_\star` marks the transition between the power-law part of
The parameter :math:`M_\star` marks the transition between the power law part of
the luminosity function and the exponential bright-end cutoff. The parameter
:math:`\alpha` controls how rapidly the abundance rises toward fainter
magnitudes. More negative values of :math:`\alpha` produce a steeper faint end.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 2 additions & 10 deletions docs/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ API reference
=============

.. autosummary::
:toctree:
:toctree: generated
:recursive:

lfkit
lfkit.api
lfkit.api.luminosity_function
lfkit.api.conditional_luminosity_function
lfkit.api.corrections
lfkit.luminosity_functions
lfkit.photometry
lfkit.corrections
lfkit.cosmo
lfkit
6 changes: 3 additions & 3 deletions docs/examples/conditional_luminosity_function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mass, or another quantity.

LFKit exposes conditional luminosity functions through
:class:`lfkit.ConditionalLuminosityFunction`. Each constructor returns a
luminosity-function object that can be evaluated with
luminosity function object that can be evaluated with
``lf.phi`` and integrated through the usual ``lf.integrals`` namespace.

The examples below use redshift as the conditioning variable because this is
Expand Down Expand Up @@ -127,7 +127,7 @@ population evolves.
Conditional Schechter surface
-----------------------------

The same conditional Schechter model can be evaluated over the full
The same conditional luminosity function model can be evaluated over the full
magnitude-redshift plane rather than at a few selected redshifts.

The filled colour scale shows :math:`\log_{10}\Phi(M \mid z)`. The contours
Expand Down Expand Up @@ -423,7 +423,7 @@ It is useful to compare the component shapes at fixed condition before combining
them into more complicated models. This separates differences in functional
form from differences caused by redshift or halo-mass evolution.

The standard Schechter form has a power-law faint end and an exponential
The standard Schechter form has a power law faint end and an exponential
bright-end cutoff. The modified Schechter component has a broader bright-end
shape. The lognormal component is localized around a characteristic luminosity.
Together, these examples show the kinds of galaxy populations each component is
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/lf_models/composite_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
|lfkitlogo| Composite models
=============================

Composite models combine multiple luminosity-function components. They are
Composite models combine multiple luminosity function components. They are
useful when a population is better described as a mixture rather than by one
single analytic shape.

Expand Down Expand Up @@ -83,7 +83,7 @@ function with a suppressed bright end.
Luminosity cutoff modifier
--------------------------

A luminosity cutoff can be applied to an existing luminosity-function object.
A luminosity cutoff can be applied to an existing luminosity function object.
This keeps the base model unchanged and returns a new object whose
:meth:`lfkit.LuminosityFunction.phi` values are multiplied by a bright-end
cutoff.
Expand Down
8 changes: 4 additions & 4 deletions docs/examples/lf_models/power_law_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ a Schechter-like exponential cutoff.
Single power law
----------------

The single power-law model has one slope. In magnitude space, this gives a
The single power law model has one slope. In magnitude space, this gives a
straight-line trend when shown on a logarithmic :math:`\Phi(M)` axis.

.. plot::
Expand Down Expand Up @@ -58,7 +58,7 @@ straight-line trend when shown on a logarithmic :math:`\Phi(M)` axis.
r"$\Phi(M)$ [$\mathrm{Mpc}^{-3}\,\mathrm{mag}^{-1}$]",
fontsize=LABEL_SIZE,
)
ax.set_title("Single power-law luminosity functions", fontsize=TITLE_SIZE)
ax.set_title("Single power law luminosity functions", fontsize=TITLE_SIZE)
ax.tick_params(axis="both", labelsize=TICK_SIZE)
ax.legend(frameon=True, fontsize=LEGEND_SIZE, loc="best")
plt.tight_layout()
Expand Down Expand Up @@ -148,7 +148,7 @@ and faint sides need different behaviour without using a Schechter cutoff.
Log-normalized power law
------------------------

The log-normalized power-law model is the same power-law shape, but the
The log-normalized power law model is the same power law shape, but the
normalization is supplied as ``log_phi_star``. This is convenient for fitting
or sampling applications where the normalization is naturally varied in
logarithmic space.
Expand Down Expand Up @@ -199,7 +199,7 @@ logarithmic space.
r"$\Phi(M)$ [$\mathrm{Mpc}^{-3}\,\mathrm{mag}^{-1}$]",
fontsize=LABEL_SIZE,
)
ax.set_title("Log-normalized power-law models", fontsize=TITLE_SIZE)
ax.set_title("Log-normalized power law models", fontsize=TITLE_SIZE)
ax.tick_params(axis="both", labelsize=TICK_SIZE)
ax.legend(frameon=True, fontsize=LEGEND_SIZE, loc="best")
plt.tight_layout()
2 changes: 1 addition & 1 deletion docs/examples/lf_models/schechter_models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
|lfkitlogo| Schechter family models
===================================

The Schechter family contains luminosity functions with a power-law faint end
The Schechter family contains luminosity functions with a power law faint end
and a bright-end cutoff. These models are commonly used when the abundance of
faint galaxies rises approximately as a power law, while the most luminous
galaxies are exponentially rare.
Expand Down
42 changes: 15 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,20 +120,18 @@ commands = [
]

[tool.tox.env.docs]
description = "Build docs with Sphinx and doctest"
description = "Build docs with Sphinx"
extras = ["docs", "viz"]
commands = [
[
"sphinx-apidoc",
"-d", "2",
"-o", "{tox_root}/docs/api",
"{tox_root}/src/lfkit",
"--separate",
"--no-toc",
"-f",
"rm",
"-rf",
"{tox_root}/docs/_build",
"{tox_root}/docs/api/generated",
],
[
"sphinx-build",
"-E",
"-c", "{tox_root}/docs",
"-b", "{posargs:html}",
"{tox_root}/docs",
Expand All @@ -144,34 +142,26 @@ commands = [

[tool.tox.env.do]
description = "Run doctests + html build and open local docs"
recreate = true
extras = ["docs", "viz"]
allowlist_externals = ["open", "rm"]
commands = [
[
"rm",
"-rf",
"{tox_root}/docs/_build/doctest",
"{tox_root}/docs/_build/html",
],
[
"sphinx-apidoc",
"-d", "2",
"-o", "{tox_root}/docs/api",
"{tox_root}/src/lfkit",
"--separate",
"--no-toc",
"-f",
"{tox_root}/docs/_build",
"{tox_root}/docs/api/generated",
],
[
"sphinx-build",
"-E",
"-b", "doctest",
"{tox_root}/docs",
"{tox_root}/docs/_build/doctest",
"--fail-on-warning",
],
[
"sphinx-build",
"-E",
"-b", "html",
"{tox_root}/docs",
"{tox_root}/docs/_build/html",
Expand All @@ -183,15 +173,13 @@ commands = [
[tool.tox.env.docs-releases]
description = "Build the documentation for lfkit releases using Sphinx"
extras = ["docs", "viz"]
allowlist_externals = ["cp"]
allowlist_externals = ["cp", "rm"]
commands = [
[
"sphinx-apidoc",
"-d", "2",
"-o", "{tox_root}/docs/api",
"{tox_root}/src/lfkit",
"--separate",
"-f",
"rm",
"-rf",
"{tox_root}/docs/_build",
"{tox_root}/docs/api/generated",
],
[
"sphinx-multiversion",
Expand Down
61 changes: 52 additions & 9 deletions src/lfkit/api/_namespaces.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""User-facing luminosity-function API namespaces."""
"""User-facing luminosity function API namespaces."""

from __future__ import annotations

Expand All @@ -14,28 +14,43 @@


class LFIntegralsAPI:
"""Grouped API for luminosity function integrals."""
"""Grouped API for luminosity function integrals.

Args:
lf: Luminosity function object whose callable form is used by bound
integral methods.
"""

def __init__(self, lf) -> None:
self.lf = lf


class LFCompletenessAPI:
"""Grouped API for catalog-completeness calculations."""
"""Grouped API for catalog completeness calculations.

Args:
lf: Luminosity function object whose callable form is used by bound
completeness methods.
"""

def __init__(self, lf) -> None:
self.lf = lf


class LFRedshiftDensityAPI:
"""Grouped API for LF-weighted redshift-density calculations."""
"""Grouped API for luminosity function weighted redshift density calculations.

Args:
lf: Luminosity function object whose callable form is used by bound
redshift density methods.
"""

def __init__(self, lf) -> None:
self.lf = lf


class LFMagnitudesAPI:
"""Grouped API for apparent- and absolute-magnitude conversions."""
"""Grouped API for apparent magnitude and absolute magnitude conversions."""


class LFLuminositiesAPI:
Expand Down Expand Up @@ -76,7 +91,20 @@ def expose_lf_function(
lf_arg_position: int | None = None,
lf_arg_name: str | None = None,
) -> Callable[..., Any]:
"""Expose a low-level LF function as a bound API method."""
"""Expose a low level luminosity function helper as a bound API method.

Args:
function: Low level function to expose as a method.
lf_arg_position: Positional index where the luminosity function callable
should be inserted. If ``None``, no positional luminosity function
argument is inserted.
lf_arg_name: Keyword name used to pass the luminosity function callable.
If provided, this takes priority over ``lf_arg_position``.

Returns:
Bound method that injects ``self.lf._as_callable()`` before calling
``function``.
"""

@wraps(function)
def method(self, *args, **kwargs):
Expand All @@ -97,7 +125,14 @@ def method(self, *args, **kwargs):


def _public_functions(module: object) -> dict[str, Callable[..., Any]]:
"""Return callable public functions declared by a module."""
"""Return callable public functions declared by a module.

Args:
module: Module object with an optional ``__all__`` declaration.

Returns:
Dictionary mapping public function names to callable objects.
"""
return {
name: getattr(module, name)
for name in getattr(module, "__all__", [])
Expand All @@ -106,13 +141,21 @@ def _public_functions(module: object) -> dict[str, Callable[..., Any]]:


def _method_name(module: object, function_name: str) -> str:
"""Return API method name for a low-level function."""
"""Return the API method name for a low level function.

Args:
module: Module object that may define ``__api_aliases__``.
function_name: Name of the low level function.

Returns:
Public API method name, using ``__api_aliases__`` when available.
"""
aliases = getattr(module, "__api_aliases__", {})
return aliases.get(function_name, function_name)


def _attach_api_methods() -> None:
"""Attach low-level functions to their API namespace classes."""
"""Attach low level functions to their API namespace classes."""
for api_cls, spec in _API_NAMESPACES.items():
module = spec["module"]
bound_to_lf = spec.get("bound_to_lf", False)
Expand Down
Loading
Loading