Skip to content

Commit

Permalink
Merge branch 'main' into paddy/issue-273
Browse files Browse the repository at this point in the history
  • Loading branch information
paddyroddy authored Nov 27, 2024
2 parents 14b7a2f + 79ecfc4 commit 6d49ee2
Show file tree
Hide file tree
Showing 6 changed files with 694 additions and 19 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,10 @@
name: Release

on:
workflow_dispatch:
inputs:
target:
default: testpypi
description: Deployment target. Can be pypi or testpypi.
release:
types:
- published
workflow_dispatch:

jobs:
dist:
Expand Down Expand Up @@ -55,8 +51,16 @@ jobs:
needs: dist
runs-on: ubuntu-latest
environment:
name: publish
url: https://pypi.org/p/glass
name: >-
${{ (github.event_name == 'release' &&
github.event.action == 'published') &&
'publish' ||
'test-publish' }}
url: >-
${{ (github.event_name == 'release' &&
github.event.action == 'published') &&
'https://pypi.org/project/glass' ||
'https://test.pypi.org/project/glass' }}
permissions:
id-token: write
steps:
Expand All @@ -71,12 +75,11 @@ jobs:

- name: Publish to PyPI
if: >-
github.event.inputs.target == 'pypi' || (github.event_name ==
'release' && github.event.action == 'published')
github.event_name == 'release' && github.event.action == 'published'
uses: pypa/gh-action-pypi-publish@release/v1

- name: Publish to TestPyPI
if: github.event.inputs.target == 'testpypi'
if: github.event_name == 'workflow_dispatch'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
115 changes: 113 additions & 2 deletions glass/lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,117 @@
from glass.shells import RadialWindow


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[True] = True,
deflection: typing.Literal[False] = False,
shear: typing.Literal[False] = False,
discretized: bool = True,
) -> tuple[npt.NDArray[np.float64]]:
# returns psi
...


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[False] = False,
deflection: typing.Literal[True] = True,
shear: typing.Literal[False] = False,
discretized: bool = True,
) -> tuple[npt.NDArray[np.complex128]]:
# returns alpha
...


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[False] = False,
deflection: typing.Literal[False] = False,
shear: typing.Literal[True] = True,
discretized: bool = True,
) -> tuple[npt.NDArray[np.complex128]]:
# returns gamma
...


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[True] = True,
deflection: typing.Literal[True] = True,
shear: typing.Literal[False] = False,
discretized: bool = True,
) -> tuple[
npt.NDArray[np.float64],
npt.NDArray[np.complex128],
]:
# returns psi, alpha
...


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[True] = True,
deflection: typing.Literal[False] = False,
shear: typing.Literal[True] = True,
discretized: bool = True,
) -> tuple[
npt.NDArray[np.float64],
npt.NDArray[np.complex128],
]:
# returns psi, gamma
...


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[False] = False,
deflection: typing.Literal[True] = True,
shear: typing.Literal[True] = True,
discretized: bool = True,
) -> tuple[
npt.NDArray[np.complex128],
npt.NDArray[np.complex128],
]:
# returns alpha, gamma
...


@typing.overload
def from_convergence(
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
*,
potential: typing.Literal[True] = True,
deflection: typing.Literal[True] = True,
shear: typing.Literal[True] = True,
discretized: bool = True,
) -> tuple[
npt.NDArray[np.float64],
npt.NDArray[np.complex128],
npt.NDArray[np.complex128],
]:
# returns psi, alpha, gamma
...


def from_convergence( # noqa: PLR0913
kappa: npt.NDArray[np.float64],
lmax: int | None = None,
Expand All @@ -53,7 +164,7 @@ def from_convergence( # noqa: PLR0913
deflection: bool = False,
shear: bool = False,
discretized: bool = True,
) -> tuple[npt.NDArray[np.float64], ...]:
) -> tuple[npt.NDArray[np.float64] | npt.NDArray[np.complex128], ...]:
r"""
Compute other weak lensing maps from the convergence.
Expand Down Expand Up @@ -175,7 +286,7 @@ def from_convergence( # noqa: PLR0913
ell = np.arange(lmax + 1)

# this tuple will be returned
results: tuple[npt.NDArray[np.float64], ...] = ()
results: tuple[npt.NDArray[np.float64] | npt.NDArray[np.complex128], ...] = ()

# convert convergence to potential
fl = np.divide(-2, ell * (ell + 1), where=(ell > 0), out=np.zeros(lmax + 1))
Expand Down
10 changes: 5 additions & 5 deletions glass/observations.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def gaussian_nz(
mean: float | npt.NDArray[np.float64],
sigma: float | npt.NDArray[np.float64],
*,
norm: npt.NDArray[np.float64] | None = None,
norm: float | npt.NDArray[np.float64] | None = None,
) -> npt.NDArray[np.float64]:
"""
Gaussian redshift distribution.
Expand Down Expand Up @@ -130,11 +130,11 @@ def gaussian_nz(

def smail_nz(
z: npt.NDArray[np.float64],
z_mode: npt.NDArray[np.float64],
alpha: npt.NDArray[np.float64],
beta: npt.NDArray[np.float64],
z_mode: float | npt.NDArray[np.float64],
alpha: float | npt.NDArray[np.float64],
beta: float | npt.NDArray[np.float64],
*,
norm: npt.NDArray[np.float64] | None = None,
norm: float | npt.NDArray[np.float64] | None = None,
) -> npt.NDArray[np.float64]:
r"""
Redshift distribution following Smail et al. (1994).
Expand Down
Loading

0 comments on commit 6d49ee2

Please sign in to comment.