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
18 changes: 15 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,21 @@ jobs:
needs: linting
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.10", "3.11", "3.12", "3.13"]
include:
- os: ubuntu-latest
python-version: "3.10"
tox-env: py310
- os: ubuntu-latest
python-version: "3.11"
tox-env: py311
- os: ubuntu-latest
python-version: "3.12"
tox-env: py312
- os: ubuntu-latest
python-version: "3.13"
tox-env: py313

steps:
- uses: actions/checkout@v4
Expand All @@ -49,7 +61,7 @@ jobs:
run: uv sync --extra dev

- name: Run tests
run: uv run tox -m test
run: uv run tox -e ${{ matrix.tox-env }}

finalise:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ __pycache__/
.pytest_cache/
.ruff_cache/
.mypy_cache/
.pyre/
.cache/
.coverage
.coverage.*
coverage.xml
htmlcov/

# Virtual environments
.venv/
venv/
env/
ENV/
.tox/
.nox/

Expand Down Expand Up @@ -42,6 +45,14 @@ Thumbs.db
# IDE files
.vscode/
.idea/
*.iml

# PyCharm
.idea/
*.iws
*.ipr
*.iml
.idea_modules/

# Local env files
.env
Expand Down
10 changes: 0 additions & 10 deletions docs/_build/html/index.html

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13 changes: 10 additions & 3 deletions src/plima/backends/ccl/la.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,15 @@ def make_ccl_la_ia_bias(
validate_greater_than(z_array, threshold=-1.0, name="z")

if amplitude is None:
ia_bias = la_amplitude(z_array, a_ia=a_ia)
physical_amplitude = la_amplitude(z_array, a_ia=a_ia)
else:
amplitude_array = as_finite_float_array(amplitude, name="amplitude")

try:
ia_bias = np.broadcast_to(amplitude_array, z_array.shape).astype(
physical_amplitude = np.broadcast_to(
amplitude_array,
z_array.shape,
).astype(
np.float64,
copy=True,
)
Expand All @@ -66,4 +69,8 @@ def make_ccl_la_ia_bias(
)
raise ValueError(msg) from error

return z_array.astype(np.float64, copy=True), ia_bias.astype(np.float64, copy=True)
ia_bias = -physical_amplitude

return z_array.astype(np.float64, copy=True), ia_bias.astype(
np.float64, copy=True
)
35 changes: 26 additions & 9 deletions src/plima/backends/ccl/nla.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
This module connects PLIMA NLA amplitude models to the IA bias tuple expected
by CCL weak lensing tracers.

The NLA amplitude model lives in ``plima.models.nla``. This file only prepares
the ``(z, ia_bias)`` tuple used by CCL.
The backend independent NLA model uses a positive physical ``A_IA`` and applies
the physical NLA response sign internally. CCL weak lensing tracers use the
opposite sign convention for the IA bias tuple, so this backend flips the sign
before returning ``(z, ia_bias)``.
"""

from __future__ import annotations
Expand All @@ -29,14 +31,22 @@ def make_ccl_nla_ia_bias(
) -> tuple[FloatArray, FloatArray]:
"""Return a CCL IA bias tuple for NLA.

This backend follows the PLIMA user-facing convention that positive
``A_IA`` corresponds to a positive physical NLA amplitude. The sign needed
by CCL weak lensing tracers is applied internally, so the returned
``ia_bias`` is ``-amplitude``.

Args:
z: Redshift values where the IA bias should be sampled.
amplitude: Optional precomputed NLA amplitude evaluated at ``z``. If
``None``, the amplitude is computed from ``nla_amplitude``.
a_ia: NLA amplitude normalization used when ``amplitude`` is ``None``.
amplitude: Optional precomputed positive physical NLA amplitude
evaluated at ``z``. If ``None``, the amplitude is computed from
``nla_amplitude``.
a_ia: Positive physical NLA amplitude normalization used when
``amplitude`` is ``None``.

Returns:
Redshift values and IA bias values sampled on the same grid.
Redshift values and CCL sign convention IA bias values sampled on the
same grid.

Raises:
ValueError: If redshifts are not finite, redshifts are outside the
Expand All @@ -50,12 +60,15 @@ def make_ccl_nla_ia_bias(
validate_greater_than(z_array, threshold=-1.0, name="z")

if amplitude is None:
ia_bias = nla_amplitude(z_array, a_ia=a_ia)
physical_amplitude = nla_amplitude(z_array, a_ia=a_ia)
else:
amplitude_array = as_finite_float_array(amplitude, name="amplitude")

try:
ia_bias = np.broadcast_to(amplitude_array, z_array.shape).astype(
physical_amplitude = np.broadcast_to(
amplitude_array,
z_array.shape,
).astype(
np.float64,
copy=True,
)
Expand All @@ -66,4 +79,8 @@ def make_ccl_nla_ia_bias(
)
raise ValueError(msg) from error

return z_array.astype(np.float64, copy=True), ia_bias.astype(np.float64, copy=True)
ia_bias = -physical_amplitude

return z_array.astype(np.float64, copy=True), ia_bias.astype(
np.float64, copy=True
)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Loading