Skip to content

Commit

Permalink
gh-107: add all public functions/classes under glass namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Sep 16, 2024
1 parent 12f3265 commit 080ee4c
Show file tree
Hide file tree
Showing 10 changed files with 102 additions and 33 deletions.
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[flake8]
ignore = E226,E501,E741
per-file-ignores =
glass/__init__.py:F401
69 changes: 68 additions & 1 deletion glass/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,71 @@
try:
from ._version import __version__, __version_tuple__ # noqa: F401
from glass._version import __version__, __version_tuple__
except ModuleNotFoundError:
pass

from glass.fields import (
iternorm,
cls2cov,
multalm,
transform_cls,
gaussian_gls,
lognormal_gls,
generate_gaussian,
generate_lognormal,
getcl,
effective_cls,
)
from glass.galaxies import (
redshifts,
redshifts_from_nz,
galaxy_shear,
gaussian_phz,
)
from glass.lensing import (
from_convergence,
shear_from_convergence,
MultiPlaneConvergence,
multi_plane_matrix,
multi_plane_weights,
deflect,
)
from glass.observations import (
vmap_galactic_ecliptic,
gaussian_nz,
smail_nz,
fixed_zbins,
equal_dens_zbins,
tomo_nz_gausserr,
)
from glass.points import (
effective_bias,
linear_bias,
loglinear_bias,
positions_from_delta,
uniform_positions,
position_weights,
)
from glass.shapes import (
triaxial_axis_ratio,
ellipticity_ryden04,
ellipticity_gaussian,
ellipticity_intnorm,
)
from glass.shells import (
distance_weight,
volume_weight,
density_weight,
tophat_windows,
linear_windows,
cubic_windows,
restrict,
partition,
partition_lstsq,
partition_nnls,
partition_restrict,
redshift_grid,
distance_grid,
combine,
RadialWindow,
)
from glass.user import save_cls, load_cls, write_catalog
6 changes: 3 additions & 3 deletions glass/fields.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Random fields (:mod:`glass.fields`)
===================================
Random fields
=============
.. currentmodule:: glass.fields
.. currentmodule:: glass
The :mod:`glass.fields` module provides functionality for simulating random
fields on the sphere. This is done in the form of HEALPix maps.
Expand Down
10 changes: 5 additions & 5 deletions glass/galaxies.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Galaxies (:mod:`glass.galaxies`)
================================
Galaxies
========
.. currentmodule:: glass.galaxies
.. currentmodule:: glass
The :mod:`glass.galaxies` module provides functionality for simulating galaxies
as typically observed in a cosmological galaxy survey.
Expand All @@ -26,8 +26,8 @@

from numpy.typing import ArrayLike

from .core.array import broadcast_leading_axes, cumtrapz
from .shells import RadialWindow
from glass.core.array import broadcast_leading_axes, cumtrapz
from glass.shells import RadialWindow


def redshifts(n: int | ArrayLike, w: RadialWindow, *,
Expand Down
8 changes: 4 additions & 4 deletions glass/lensing.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Lensing (:mod:`glass.lensing`)
==============================
Lensing
=======
.. currentmodule:: glass.lensing
.. currentmodule:: glass
The :mod:`glass.lensing` module provides functionality for simulating
gravitational lensing by the matter distribution in the universe.
Expand Down Expand Up @@ -40,7 +40,7 @@
if TYPE_CHECKING:
# to prevent circular dependencies, only import these for type checking
from cosmology import Cosmology
from .shells import RadialWindow
from glass.shells import RadialWindow


def from_convergence(kappa: NDArray, lmax: Optional[int] = None, *,
Expand Down
8 changes: 4 additions & 4 deletions glass/observations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Observations (:mod:`glass.observations`)
========================================
Observations
============
.. currentmodule:: glass.observations
.. currentmodule:: glass
The :mod:`glass.observations` module provides functionality for simulating
observational effects of surveys.
Expand Down Expand Up @@ -35,7 +35,7 @@
from typing import Optional, Tuple, List
from numpy.typing import ArrayLike

from .core.array import cumtrapz
from glass.core.array import cumtrapz


def vmap_galactic_ecliptic(nside: int, galactic: Tuple[float, float] = (30, 90),
Expand Down
10 changes: 5 additions & 5 deletions glass/points.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Random points (:mod:`glass.points`)
===================================
Random points
=============
.. currentmodule:: glass.points
.. currentmodule:: glass
The :mod:`glass.points` module provides functionality for simulating point
processes on the sphere and sampling random positions.
Expand Down Expand Up @@ -34,8 +34,8 @@
import numpy as np
import healpix

from .core.array import broadcast_first, broadcast_leading_axes, trapz_product
from .core.constants import ARCMIN2_SPHERE
from glass.core.array import broadcast_first, broadcast_leading_axes, trapz_product
from glass.core.constants import ARCMIN2_SPHERE


def effective_bias(z, bz, w):
Expand Down
6 changes: 3 additions & 3 deletions glass/shapes.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Observed shapes (:mod:`glass.shapes`)
=====================================
Observed shapes
===============
.. currentmodule:: glass.shapes
.. currentmodule:: glass
The :mod:`glass.shapes` module provides functionality for simulating the
observed shapes of objects, such as e.g. galaxies.
Expand Down
10 changes: 5 additions & 5 deletions glass/shells.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
Shells (:mod:`glass.shells`)
============================
Shells
======
.. currentmodule:: glass.shells
.. currentmodule:: glass
The :mod:`glass.shells` module provides functions for the definition of
matter shells, i.e. the radial discretisation of the light cone.
Expand Down Expand Up @@ -49,7 +49,7 @@
from collections import namedtuple
import numpy as np

from .core.array import ndinterp
from glass.core.array import ndinterp

# type checking
from typing import (Union, Sequence, List, Tuple, Optional, Callable,
Expand Down Expand Up @@ -503,7 +503,7 @@ def partition_nnls(
"""

from .core.algorithm import nnls
from glass.core.algorithm import nnls

# make sure nothing breaks
if sumtol < 1e-4:
Expand Down
6 changes: 3 additions & 3 deletions glass/user.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# author: Nicolas Tessore <[email protected]>
# license: MIT
'''
User utilities (:mod:`glass.user`)
==================================
User utilities
==============
.. currentmodule:: glass.user
.. currentmodule:: glass
The :mod:`glass.user` module contains convenience functions for users of the
library.
Expand Down

0 comments on commit 080ee4c

Please sign in to comment.