Skip to content

Commit

Permalink
Merge branch 'main' into saransh/test_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp authored Nov 26, 2024
2 parents d1bbeea + ea3cb74 commit 570172c
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ on:

jobs:
check-pr-title:
if: github.actor != 'pre-commit-ci[bot]'
if:
github.actor != 'pre-commit-ci[bot]' && github.actor != 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Enfore PR title format
uses: thehanimo/[email protected].2
uses: thehanimo/[email protected].3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
pass_on_octokit_error: false
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
args:
- --strict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.4
rev: v0.8.0
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -44,15 +44,15 @@ repos:
additional_dependencies:
- black
- repo: https://github.com/pappasam/toml-sort
rev: v0.24.1
rev: v0.24.2
hooks:
- id: toml-sort-fix
- repo: https://github.com/rbubley/mirrors-prettier
rev: v3.3.3
hooks:
- id: prettier
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.42.0
rev: v0.43.0
hooks:
- id: markdownlint-fix
args:
Expand Down
4 changes: 2 additions & 2 deletions glass/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""GLASS package."""

__all__ = [
"MultiPlaneConvergence",
"RadialWindow",
"cls2cov",
"combine",
"cubic_windows",
Expand Down Expand Up @@ -32,11 +34,9 @@
"multalm",
"multi_plane_matrix",
"multi_plane_weights",
"MultiPlaneConvergence",
"partition",
"position_weights",
"positions_from_delta",
"RadialWindow",
"redshift_grid",
"redshifts",
"redshifts_from_nz",
Expand Down
38 changes: 38 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,45 @@
import numpy as np
import numpy.typing as npt
import pytest

from cosmology import Cosmology

from glass import RadialWindow


@pytest.fixture(scope="session")
def cosmo() -> Cosmology:
class MockCosmology:
@property
def omega_m(self) -> float:
return 0.3

def ef(self, z: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
return (self.omega_m * (1 + z) ** 3 + 1 - self.omega_m) ** 0.5

def xm(
self,
z: npt.NDArray[np.float64],
z2: npt.NDArray[np.float64] | None = None,
) -> npt.NDArray[np.float64]:
if z2 is None:
return np.array(z) * 1000
return (np.array(z2) - np.array(z)) * 1000

return MockCosmology()


@pytest.fixture(scope="session")
def rng() -> np.random.Generator:
return np.random.default_rng(seed=42)


@pytest.fixture(scope="session")
def shells() -> list[RadialWindow]:
return [
RadialWindow(np.array([0.0, 1.0, 2.0]), np.array([0.0, 1.0, 0.0]), 1.0),
RadialWindow(np.array([1.0, 2.0, 3.0]), np.array([0.0, 1.0, 0.0]), 2.0),
RadialWindow(np.array([2.0, 3.0, 4.0]), np.array([0.0, 1.0, 0.0]), 3.0),
RadialWindow(np.array([3.0, 4.0, 5.0]), np.array([0.0, 1.0, 0.0]), 4.0),
RadialWindow(np.array([4.0, 5.0, 6.0]), np.array([0.0, 1.0, 0.0]), 5.0),
]
34 changes: 0 additions & 34 deletions tests/test_lensing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import healpix
import numpy as np
import numpy.typing as npt
import pytest

from glass import (
Expand All @@ -19,39 +18,6 @@
from cosmology import Cosmology


@pytest.fixture
def shells() -> list[RadialWindow]:
return [
RadialWindow(np.array([0.0, 1.0, 2.0]), np.array([0.0, 1.0, 0.0]), 1.0),
RadialWindow(np.array([1.0, 2.0, 3.0]), np.array([0.0, 1.0, 0.0]), 2.0),
RadialWindow(np.array([2.0, 3.0, 4.0]), np.array([0.0, 1.0, 0.0]), 3.0),
RadialWindow(np.array([3.0, 4.0, 5.0]), np.array([0.0, 1.0, 0.0]), 4.0),
RadialWindow(np.array([4.0, 5.0, 6.0]), np.array([0.0, 1.0, 0.0]), 5.0),
]


@pytest.fixture
def cosmo() -> Cosmology:
class MockCosmology:
@property
def omega_m(self) -> float:
return 0.3

def ef(self, z: npt.NDArray[np.float64]) -> npt.NDArray[np.float64]:
return (self.omega_m * (1 + z) ** 3 + 1 - self.omega_m) ** 0.5

def xm(
self,
z: npt.NDArray[np.float64],
z2: npt.NDArray[np.float64] | None = None,
) -> npt.NDArray[np.float64]:
if z2 is None:
return np.array(z) * 1000
return (np.array(z2) - np.array(z)) * 1000

return MockCosmology()


@pytest.mark.parametrize("usecomplex", [True, False])
def test_deflect_nsew(usecomplex: bool) -> None: # noqa: FBT001
d = 5.0
Expand Down

0 comments on commit 570172c

Please sign in to comment.