Skip to content

Commit

Permalink
Merge pull request #208 from halomod/pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
[pre-commit.ci] pre-commit autoupdate
  • Loading branch information
steven-murray authored Apr 15, 2024
2 parents ad2fe5a + 0288372 commit f1fd037
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exclude: '^docs/conf.py'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: trailing-whitespace
- id: check-added-large-files
Expand Down Expand Up @@ -33,7 +33,7 @@ repos:
- flake8-print
# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 23.12.1
rev: 24.3.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pygrep-hooks
Expand All @@ -46,7 +46,7 @@ repos:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
rev: v3.15.2
hooks:
- id: pyupgrade
args: [--py38-plus]
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Setup the package."""

from setuptools import setup

setup()
1 change: 1 addition & 0 deletions src/hmf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A package for producing halo mass functions under Spherical Collapse."""

try:
from importlib.metadata import PackageNotFoundError, version
except ImportError:
Expand Down
1 change: 1 addition & 0 deletions src/hmf/_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Module that contains the command line app."""

import click
import importlib
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/hmf/_internals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
These define the structure of the entire library.
"""

from ._cache import cached_quantity, parameter
from ._framework import (
Component,
Expand Down
7 changes: 4 additions & 3 deletions src/hmf/_internals/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
functionality of being automatically updated when a parent property is
updated.
"""

import warnings
from copy import deepcopy
from functools import update_wrapper
Expand Down Expand Up @@ -104,9 +105,9 @@ def _get_property(self):
# if name is already there, can only be because the method has been supered.
supered = name in activeq
if not supered:
recalc_prpa[
name
] = set() # Empty set to which parameter names will be added
recalc_prpa[name] = (
set()
) # Empty set to which parameter names will be added
activeq.add(name)

# Go ahead and calculate the value -- each parameter accessed will add itself to the index.
Expand Down
1 change: 1 addition & 0 deletions src/hmf/_internals/_framework.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Classes defining the overall structure of the hmf framework."""

import copy
import deprecation
import logging
Expand Down
1 change: 1 addition & 0 deletions src/hmf/alternatives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
A subpackage dedicated to providing "plugin"-style alternatives to the standard halo mass function, for example
Warm Dark Matter cosmologies.
"""

from . import wdm
1 change: 1 addition & 0 deletions src/hmf/cosmology/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Cosmographic calculations, and other purely cosmological quantities, such as growth factor."""

from . import cosmo
from .cosmo import Cosmology, astropy_to_colossus
from .growth_factor import GrowthFactor
2 changes: 2 additions & 0 deletions src/hmf/cosmology/growth_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class _GrowthFactor(Cmpt):
r"""
General class for a growth factor calculation.
"""

supported_cosmos = (cosmology.LambdaCDM,)

def __init__(self, cosmo, **model_parameters):
Expand Down Expand Up @@ -64,6 +65,7 @@ class GrowthFactor(_GrowthFactor):
----------
.. [1] Lukic et. al., ApJ, 2007, http://adsabs.harvard.edu/abs/2007ApJ...671.1160L
"""

_defaults = {"dlna": 0.01, "amin": 1e-8}

def __init__(self, *args, **kwargs):
Expand Down
1 change: 1 addition & 0 deletions src/hmf/density_field/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
A subpackage dedicated to basic measures of the matter density field -- its 2-point structure, cosmological transfer
functions, and filter functions which can be applied to it.
"""

from . import filters, transfer, transfer_models
from .filters import Filter
from .halofit import halofit
Expand Down
1 change: 1 addition & 0 deletions src/hmf/density_field/halofit.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
and Michael Schneider (https://code.google.com/p/chomp/). It has
been modified to improve its integration with this package.
"""

import numpy as np
import warnings
from scipy.integrate import simps as _simps
Expand Down
1 change: 1 addition & 0 deletions src/hmf/density_field/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
calculate the transfer function, matter power spectrum and several other
related quantities.
"""

import numpy as np

from .._internals._cache import cached_quantity, parameter
Expand Down
7 changes: 4 additions & 3 deletions src/hmf/density_field/transfer_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Note that these are not transfer function "frameworks". The framework is found
in :mod:`hmf.transfer`.
"""

import numpy as np
import pickle
import warnings
Expand Down Expand Up @@ -462,9 +463,7 @@ def _set_params(self):
self.z_eq = 2.5e4 * self.Omh2 * self.theta_cmb ** (-4) # really 1+z
self.k_eq = 7.46e-2 * self.Omh2 * self.theta_cmb ** (-2) # units Mpc^-1 (no h!)

self.z_drag_b1 = (
0.313 * self.Omh2**-0.419 * (1.0 + 0.607 * self.Omh2**0.674)
)
self.z_drag_b1 = 0.313 * self.Omh2**-0.419 * (1.0 + 0.607 * self.Omh2**0.674)
self.z_drag_b2 = 0.238 * self.Omh2**0.223
self.z_drag = (
1291.0
Expand Down Expand Up @@ -686,6 +685,7 @@ class attribute.
.. math:: \Gamma \rightarrow \Gamma
\exp\left(-\Omega_{b,0}(1 + \sqrt{2h}/\Omega_{m,0})\right).
"""

_defaults = {
"a": 2.34,
"b": 3.89,
Expand Down Expand Up @@ -760,6 +760,7 @@ class attribute.
.. math:: \alpha = \frac{0.3\times 0.75^2}{\Omega_{m,0} h^2}.
"""

_defaults = {"a": 37.1, "b": 21.1, "c": 10.8, "nu": 1.12}

def lnt(self, lnk):
Expand Down
4 changes: 2 additions & 2 deletions src/hmf/halos/mass_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This is primarily inspired by Benedikt Diemer's COLOSSUS code:
https://bdiemer.bitbucket.io/colossus/halo_mass_defs.html
"""

import astropy.units as u
import numpy as np
import scipy as sp
Expand Down Expand Up @@ -366,8 +367,7 @@ def h(x):
return np.log(1.0 + x) - x / (1.0 + x)

fnc = (
lambda x, rhos, density_threshold: rhos * h(x) * 3.0 / x**3
- density_threshold
lambda x, rhos, density_threshold: rhos * h(x) * 3.0 / x**3 - density_threshold
)

while x is None and i < len(XDELTA_GUESS_FACTORS):
Expand Down
1 change: 1 addition & 0 deletions src/hmf/helpers/cfg_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Utilities for interacting with hmf TOML configs."""

from astropy.units import Quantity
from datetime import datetime
from inspect import signature
Expand Down
1 change: 1 addition & 0 deletions src/hmf/helpers/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Provides routines for sampling theoretical functions, and for binning sampled data.
"""

import numpy as np
from scipy.interpolate import InterpolatedUnivariateSpline as _spline

Expand Down
1 change: 1 addition & 0 deletions src/hmf/mass_function/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Subpackage for determining the halo mass function in Spherical Collapse."""

from . import fitting_functions, hmf, integrate_hmf
from .fitting_functions import PS, SMT, FittingFunction, Tinker08
from .hmf import MassFunction
8 changes: 3 additions & 5 deletions src/hmf/mass_function/fitting_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ class FittingFunction(_framework.Component):
In that example, we did not specify :attr:`cutmask`.
"""

_pdocs = r"""
Parameters
Expand Down Expand Up @@ -641,8 +642,7 @@ def fsigma(self):
* (1.0 + (1.0 / (a * self.nu**2)) ** p + 0.6 * G_1 + 0.4 * G_2)
* self.nu
* np.exp(
-c * a * self.nu**2 / 2.0
- 0.03 * self.nu**0.6 / (self.n_eff + 3) ** 2
-c * a * self.nu**2 / 2.0 - 0.03 * self.nu**0.6 / (self.n_eff + 3) ** 2
)
)

Expand Down Expand Up @@ -1516,9 +1516,7 @@ def normalise(self):
* self.beta ** (-2 * self.phi)
* self.gamma ** (-0.5 - self.eta)
* (
2**self.phi
* self.beta ** (2 * self.phi)
* sp.gamma(self.eta + 0.5)
2**self.phi * self.beta ** (2 * self.phi) * sp.gamma(self.eta + 0.5)
+ self.gamma**self.phi * sp.gamma(0.5 + self.eta - self.phi)
)
)
Expand Down
5 changes: 2 additions & 3 deletions src/hmf/mass_function/integrate_hmf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
A supporting module that provides a routine to integrate the differential hmf in a robust manner.
"""

import numpy as np
import scipy.integrate as intg
from scipy.interpolate import InterpolatedUnivariateSpline as _spline
Expand Down Expand Up @@ -64,9 +65,7 @@ def hmf_integral_gtm(M, dndm, mass_density=False):

# Calculate the mass function (and its integral) from the highest M up to 10**18
if m[-1] < m[0] * 10**18 / m[3]:
m_upper = np.arange(
np.log(m[-1]), np.log(10**18), np.log(m[1]) - np.log(m[0])
)
m_upper = np.arange(np.log(m[-1]), np.log(10**18), np.log(m[1]) - np.log(m[0]))
mf_func = _spline(np.log(m), np.log(dndlnm), k=1)
mf = mf_func(m_upper)

Expand Down
1 change: 1 addition & 0 deletions tests/test_genmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
'transfer__k_per_logint': 0,
'transfer__kmax':100.0
"""

import pytest

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions tests/test_hmf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Tests of HMF."""

from pytest import raises

import numpy as np
Expand Down
4 changes: 1 addition & 3 deletions tests/test_integrate_hmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ def anl_int(self, m, loghs, alpha, beta):
return 10**loghs * gammainc((alpha + 1) / beta, (m / 10**loghs) ** beta)

def anl_m_int(self, m, loghs, alpha, beta):
return 10 ** (2 * loghs) * gammainc(
(alpha + 2) / beta, (m / 10**loghs) ** beta
)
return 10 ** (2 * loghs) * gammainc((alpha + 2) / beta, (m / 10**loghs) ** beta)

# def test_basic(self):
# m = np.logspace(10,18,500)
Expand Down

0 comments on commit f1fd037

Please sign in to comment.