PyCosmo 2.2.0__tar.gz → 2.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. pycosmo-2.2.2/MANIFEST.in +1 -0
  2. pycosmo-2.2.2/PKG-INFO +55 -0
  3. pycosmo-2.2.2/README.md +19 -0
  4. pycosmo-2.2.2/pyproject.toml +114 -0
  5. pycosmo-2.2.2/setup.cfg +4 -0
  6. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/Background.py +4 -11
  7. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/BoltzmannSolver/LinearPerturbationBoltzmann.py +4 -35
  8. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/BoltzmannSolver/ScipySolver.py +1 -1
  9. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/Cosmo.py +12 -12
  10. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore.py +2 -0
  11. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_massivenu.py +3 -0
  12. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_massivenu_rsa.py +4 -0
  13. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_massivenu_wcdm.py +2 -0
  14. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_massivenu_wcdm_rsa.py +3 -0
  15. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_rsa.py +1 -0
  16. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_wcdm.py +1 -0
  17. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/CosmologyCore_wcdm_rsa.py +1 -0
  18. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/LinearPerturbationApprox.py +8 -6
  19. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/LinearPerturbationBase.py +5 -8
  20. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/NonLinearPerturbationHaloFit.py +8 -8
  21. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/NonLinearPerturbationMead.py +7 -7
  22. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/NonLinearPerturbation_HI.py +4 -4
  23. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/NonLinearPerturbation_HaloModel.py +7 -7
  24. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/Obs.py +6 -6
  25. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/PerturbationTable.py +1 -1
  26. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/Projection.py +5 -5
  27. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/_RecombinationCosmics.py +3 -3
  28. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/__init__.py +10 -8
  29. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/__init__.py +0 -1
  30. pycosmo-2.2.0/tests/test_pickling.py → pycosmo-2.2.2/src/PyCosmo/cython/__init__.py +9 -8
  31. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral.c +8190 -8081
  32. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_1h.c +8454 -8293
  33. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_2h.c +8884 -8737
  34. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_HI_1h.c +8976 -8845
  35. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_HI_2h.c +8735 -8601
  36. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/rho_HI_integral.c +8441 -8259
  37. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/rho_m_integral.c +8418 -8222
  38. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/optimize_nq.py +2 -2
  39. pycosmo-2.2.2/src/PyCosmo.egg-info/PKG-INFO +55 -0
  40. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo.egg-info/SOURCES.txt +3 -25
  41. pycosmo-2.2.2/src/PyCosmo.egg-info/requires.txt +10 -0
  42. pycosmo-2.2.0/PKG-INFO +0 -64
  43. pycosmo-2.2.0/README.rst +0 -18
  44. pycosmo-2.2.0/pyproject.toml +0 -45
  45. pycosmo-2.2.0/setup.cfg +0 -74
  46. pycosmo-2.2.0/src/PyCosmo/LinearPerturbationTable.py +0 -173
  47. pycosmo-2.2.0/src/PyCosmo/NonLinearPerturbationTable.py +0 -162
  48. pycosmo-2.2.0/src/PyCosmo/_Tables.py +0 -299
  49. pycosmo-2.2.0/src/PyCosmo/cython/__init__.py +0 -24
  50. pycosmo-2.2.0/src/PyCosmo.egg-info/PKG-INFO +0 -64
  51. pycosmo-2.2.0/src/PyCosmo.egg-info/requires.txt +0 -23
  52. pycosmo-2.2.0/tests/test_background.py +0 -410
  53. pycosmo-2.2.0/tests/test_boltzmann_solver.py +0 -831
  54. pycosmo-2.2.0/tests/test_class.py +0 -196
  55. pycosmo-2.2.0/tests/test_core_files_imports.py +0 -57
  56. pycosmo-2.2.0/tests/test_cosmo.py +0 -48
  57. pycosmo-2.2.0/tests/test_cython_extensions.py +0 -51
  58. pycosmo-2.2.0/tests/test_ini_handling.py +0 -45
  59. pycosmo-2.2.0/tests/test_linear_perturbation_approx.py +0 -256
  60. pycosmo-2.2.0/tests/test_massive_neutrinos.py +0 -172
  61. pycosmo-2.2.0/tests/test_nonlinear_perturbation_halofit.py +0 -129
  62. pycosmo-2.2.0/tests/test_nonlinear_perturbation_halomodel.py +0 -167
  63. pycosmo-2.2.0/tests/test_nonlinear_perturbation_mead.py +0 -216
  64. pycosmo-2.2.0/tests/test_obs.py +0 -822
  65. pycosmo-2.2.0/tests/test_perturbation_table.py +0 -84
  66. pycosmo-2.2.0/tests/test_pycosmo.py +0 -110
  67. pycosmo-2.2.0/tests/test_recombination.py +0 -19
  68. pycosmo-2.2.0/tests/test_scipy_solver.py +0 -91
  69. pycosmo-2.2.0/tests/test_util.py +0 -40
  70. {pycosmo-2.2.0 → pycosmo-2.2.2}/AUTHORS.rst +0 -0
  71. {pycosmo-2.2.0 → pycosmo-2.2.2}/LICENSE +0 -0
  72. {pycosmo-2.2.0 → pycosmo-2.2.2}/setup.py +0 -0
  73. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/BoltzmannSolver/Fields.py +0 -0
  74. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/BoltzmannSolver/LsodaSolver.py +0 -0
  75. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/BoltzmannSolver/__init__.py +0 -0
  76. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/PerturbationBase.py +0 -0
  77. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/TheoryPredTables.py +0 -0
  78. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/_Cosmics.py +0 -0
  79. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/_Recombination.py +0 -0
  80. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/_RecombinationClass.py +0 -0
  81. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/_Util.py +0 -0
  82. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/_scipy_utils.py +0 -0
  83. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/build.py +0 -0
  84. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_lcdm.ini +0 -0
  85. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_lcdm_rsa.ini +0 -0
  86. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_mnulcdm.ini +0 -0
  87. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_mnulcdm_rsa.ini +0 -0
  88. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_mnuwcdm.ini +0 -0
  89. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_mnuwcdm_rsa.ini +0 -0
  90. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_wcdm.ini +0 -0
  91. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/default_wcdm_rsa.ini +0 -0
  92. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/config/load_parameters_ini.py +0 -0
  93. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/core_file_handling.py +0 -0
  94. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/const.c +0 -0
  95. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/constf.c +0 -0
  96. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral.pyx +0 -0
  97. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_1h.pyx +0 -0
  98. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_2h.pyx +0 -0
  99. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_HI_1h.pyx +0 -0
  100. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/halo_integral_HI_2h.pyx +0 -0
  101. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/logf.c +0 -0
  102. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/main.c +0 -0
  103. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/mconf.h +0 -0
  104. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/mtherr.c +0 -0
  105. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/polevl.c +0 -0
  106. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/polevlf.c +0 -0
  107. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/protos.h +0 -0
  108. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/rho_HI_integral.pyx +0 -0
  109. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/rho_m_integral.pyx +0 -0
  110. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/sici.c +0 -0
  111. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/sici.h +0 -0
  112. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/sici32.c +0 -0
  113. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/sicif.c +0 -0
  114. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/cython/sinf.c +0 -0
  115. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/disable_multithreading.py +0 -0
  116. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/ini_handling.py +0 -0
  117. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/model_config.py +0 -0
  118. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/patches.py +0 -0
  119. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo/predefined_k_grids.py +0 -0
  120. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo.egg-info/dependency_links.txt +0 -0
  121. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo.egg-info/entry_points.txt +0 -0
  122. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo.egg-info/not-zip-safe +0 -0
  123. {pycosmo-2.2.0 → pycosmo-2.2.2}/src/PyCosmo.egg-info/top_level.txt +0 -0
@@ -0,0 +1 @@
1
+ prune tests
pycosmo-2.2.2/PKG-INFO ADDED
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyCosmo
3
+ Version: 2.2.2
4
+ Summary: A multi-purpose cosmology calculation tool
5
+ Author-email: Uwe Schmitt et al <uwe.schmitt@id.ethz.ch>
6
+ License: GPLv3
7
+ Project-URL: Source, https://cosmo-docs.phys.ethz.ch/PyCosmo
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
12
+ Classifier: Natural Language :: English
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: C
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Topic :: Scientific/Engineering :: Astronomy
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown; charset=UTF-8
23
+ License-File: LICENSE
24
+ License-File: AUTHORS.rst
25
+ Requires-Dist: numpy>=2
26
+ Requires-Dist: recfast4py>=0.2.3
27
+ Requires-Dist: dill
28
+ Requires-Dist: matplotlib
29
+ Requires-Dist: numba>=0.60
30
+ Requires-Dist: sympy2c>=2.3.1
31
+ Requires-Dist: numexpr>=2.10
32
+ Requires-Dist: scipy
33
+ Requires-Dist: setuptools>=75.6.0
34
+ Requires-Dist: mpmath==1.3
35
+ Dynamic: license-file
36
+
37
+ # PyCosmo
38
+
39
+ PyCosmo is a multi-purpose cosmology calculation tool in Python. It is
40
+ designed to be interactive and user friendly.
41
+
42
+ The code includes calculations of:
43
+ - Background
44
+ - Linear perturbations (incl. fitting functions and a Boltzmann solver)
45
+ - Non-linear perturbations
46
+ - Series of observables (e.g., weak lensing and galaxy clustering
47
+ power spectrum, ...)
48
+ - Several model extensions (massive neutrinos, wCDM, ...)
49
+
50
+
51
+ The code documentation can be found at
52
+ [https://cosmo-docs.phys.ethz.ch/PyCosmo](https://cosmo-docs.phys.ethz.ch/PyCosmo)
53
+
54
+ Interactive tutorial notebooks are available on the
55
+ [PyCosmoHUB](https://pycosmohub.com).
@@ -0,0 +1,19 @@
1
+ # PyCosmo
2
+
3
+ PyCosmo is a multi-purpose cosmology calculation tool in Python. It is
4
+ designed to be interactive and user friendly.
5
+
6
+ The code includes calculations of:
7
+ - Background
8
+ - Linear perturbations (incl. fitting functions and a Boltzmann solver)
9
+ - Non-linear perturbations
10
+ - Series of observables (e.g., weak lensing and galaxy clustering
11
+ power spectrum, ...)
12
+ - Several model extensions (massive neutrinos, wCDM, ...)
13
+
14
+
15
+ The code documentation can be found at
16
+ [https://cosmo-docs.phys.ethz.ch/PyCosmo](https://cosmo-docs.phys.ethz.ch/PyCosmo)
17
+
18
+ Interactive tutorial notebooks are available on the
19
+ [PyCosmoHUB](https://pycosmohub.com).
@@ -0,0 +1,114 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 64", "numpy", "Cython"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+
6
+ [project]
7
+ name = "PyCosmo"
8
+ version = "2.2.2"
9
+ license = {text = "GPLv3"}
10
+ description = "A multi-purpose cosmology calculation tool"
11
+ authors = [{name = "Uwe Schmitt et al", email = "uwe.schmitt@id.ethz.ch"}]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "Intended Audience :: Science/Research",
16
+ "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
17
+ "Natural Language :: English",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: C",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.11",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.9",
25
+ "Topic :: Scientific/Engineering :: Astronomy",
26
+ ]
27
+
28
+ urls = {Source = "https://cosmo-docs.phys.ethz.ch/PyCosmo"}
29
+ requires-python = ">=3.10"
30
+ dependencies = [
31
+ "numpy>=2",
32
+ "recfast4py>=0.2.3",
33
+ "dill",
34
+ "matplotlib",
35
+ "numba>=0.60",
36
+ "sympy2c>=2.3.1",
37
+ "numexpr>=2.10",
38
+ "scipy",
39
+ "setuptools>=75.6.0",
40
+ "mpmath==1.3",
41
+ ]
42
+
43
+ [project.readme]
44
+ file = "README.md"
45
+ content-type = "text/markdown; charset=UTF-8"
46
+
47
+ [dependency-groups]
48
+ dev = [
49
+ "Cython",
50
+ "twine",
51
+ "pytest",
52
+ "pytest-cov",
53
+ "pytest-regtest>=2.2.0a2",
54
+ "ruff",
55
+ "isort",
56
+ "pre-commit",
57
+ "pdbp>=1.7.1",
58
+ "build>=1.3.0",
59
+ ]
60
+
61
+ docs = [
62
+ "sphinx < 7",
63
+ "sphinx-pynpoint-theme",
64
+ "myst-parser",
65
+ ]
66
+
67
+ [project.scripts]
68
+ recompile = "PyCosmo:Cosmo.recompile_from_cli"
69
+
70
+ [tool.setuptools]
71
+ zip-safe = false
72
+ include-package-data = true
73
+
74
+ [tool.setuptools.package-data]
75
+ "*" = [
76
+ "*.pyx",
77
+ "*.c",
78
+ "*.h",
79
+ "config/*.ini",
80
+ ]
81
+
82
+
83
+ [tool.ruff]
84
+ line-length = 88
85
+ extend-exclude = ["benchmarks/", "*.ipynb"]
86
+
87
+ [tool.ruff.format]
88
+ quote-style = "double"
89
+ line-ending = "lf"
90
+ docstring-code-format = false
91
+
92
+ [tool.ruff.lint]
93
+ extend-select = [
94
+ "RUF100", # unnecessary `noqa` directives
95
+ ]
96
+ ignore = [
97
+ "E501",
98
+ "E731", # lambda assignment
99
+ "E741", # ambiguous variable name
100
+ ]
101
+
102
+ [tool.ruff.lint.per-file-ignores]
103
+ '__init__.py' = [
104
+ "F401", # imported but unused
105
+ ]
106
+
107
+
108
+ [tool.pytest.ini_options]
109
+ testpaths = ["tests"]
110
+ addopts = ["--verbose", "--durations=0", "--durations-min=5"]
111
+ markers = [
112
+ "slow: Marks tests as slow to run. Pass `--runslow` to include them."
113
+ ]
114
+ console_output_style = "count"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -214,8 +214,7 @@ class Background(object):
214
214
  eta = np.atleast_1d(eta)
215
215
  if np.any(eta < 0.95 * self._eta_min) or np.any(eta > self._eta_max * 1.05):
216
216
  raise ValueError(
217
- f"eta value(s) outside of range {self._eta_min:e} .. "
218
- f" {self._eta_max:e}"
217
+ f"eta value(s) outside of range {self._eta_min:e} .. {self._eta_max:e}"
219
218
  )
220
219
  return self._eta_to_a(eta)
221
220
 
@@ -292,9 +291,7 @@ class Background(object):
292
291
  a = np.atleast_1d(a)
293
292
  return np.array(
294
293
  [
295
- integrate.quadrature(
296
- self._tau_intgd, np.log(aa), 0.0, rtol=1e-6, maxiter=100
297
- )[0]
294
+ integrate.fixed_quad(self._tau_intgd, np.log(aa), 0.0, n=100)[0]
298
295
  for aa in a
299
296
  ]
300
297
  )
@@ -321,9 +318,7 @@ class Background(object):
321
318
  a = np.atleast_1d(a)
322
319
  return np.array(
323
320
  [
324
- integrate.quadrature(
325
- self._tau_b_intgd, np.log(aa), 0.0, maxiter=100, rtol=5e-5
326
- )[0]
321
+ integrate.fixed_quad(self._tau_b_intgd, np.log(aa), 0.0, n=100)[0]
327
322
  for aa in a
328
323
  ]
329
324
  )
@@ -370,9 +365,7 @@ class Background(object):
370
365
  return np.inf
371
366
  a_drag = a_drag[-1]
372
367
 
373
- return integrate.quadrature(self._r_s_intg, np.log(a_drag), 0.0, rtol=1e-5)[
374
- 0
375
- ] # Mpc/h
368
+ return integrate.fixed_quad(self._r_s_intg, np.log(a_drag), 0.0, n=100)[0]
376
369
 
377
370
  def _r_s_intg(self, lna):
378
371
  a = np.exp(lna)
@@ -16,7 +16,6 @@
16
16
 
17
17
  import itertools
18
18
  import warnings
19
- from datetime import datetime
20
19
  from functools import lru_cache
21
20
  from multiprocessing import current_process
22
21
 
@@ -28,7 +27,7 @@ from .LsodaSolver import LsodaSolver
28
27
 
29
28
 
30
29
  # use decorator to print messages only once per model:
31
- @lru_cache(maxsize=1) # noqa: E302
30
+ @lru_cache(maxsize=1)
32
31
  def print_new_traces(cache_file):
33
32
  print()
34
33
  print("new traces detected! you might want to run")
@@ -39,36 +38,6 @@ def print_new_traces(cache_file):
39
38
  proc_name = current_process().name
40
39
 
41
40
 
42
- def trace_call(frame, event, arg):
43
- if proc_name.endswith("-2"):
44
- return trace_call
45
- if event in ("line",):
46
- return trace_call
47
- fname = frame.f_code.co_filename
48
- if any(
49
- n in fname
50
- for n in (
51
- "pprint",
52
- "dill",
53
- "pickle",
54
- "numba",
55
- "logging",
56
- "ini_handling",
57
- "llvmlite",
58
- "traceback",
59
- "weakref",
60
- )
61
- ):
62
- return trace_call
63
- print(datetime.now(), end=" ")
64
- fr = frame
65
- print(proc_name, f"{event:8s}", end="")
66
- while (fr := fr.f_back) is not None:
67
- print(" ", end="")
68
- print(fname, frame.f_code.co_name, frame.f_lineno, flush=True)
69
- return trace_call
70
-
71
-
72
41
  class LinearPerturbationBoltzmann(LinearPerturbationBase):
73
42
  """
74
43
  Class for computing linear perturbations by solving the Einstein-Boltzmann ODE
@@ -362,9 +331,9 @@ class LinearPerturbationBoltzmann(LinearPerturbationBase):
362
331
 
363
332
  :return: D(a): growth factor normalised to 1 at a=1 [1]
364
333
  """
365
- assert (
366
- k is not None
367
- ), "growth factor of Einstein-Boltzmann model requires a k value"
334
+ assert k is not None, (
335
+ "growth factor of Einstein-Boltzmann model requires a k value"
336
+ )
368
337
  # TODO: add option where D is normalised to a in matter dominated era
369
338
  grid = np.log(np.atleast_1d(a))
370
339
  if grid[-1] != 0.0:
@@ -300,7 +300,7 @@ def merge(wrapper, t_0, t_switch, t_1, y_0, y_1): # pragma: no cover
300
300
  + a
301
301
  * H_Mpc
302
302
  * wrapper.taudot_interp_ufunc(a)
303
- / k**2
303
+ / k** 2
304
304
  * (
305
305
  u_b
306
306
  - k / (a * H_Mpc) * wrapper.c_s_interp_ufunc(a) ** 2 * delta_b
@@ -425,33 +425,33 @@ class Cosmo(object):
425
425
  raise ValueError("unknown pk_type value {} used".format(params.pk_type))
426
426
 
427
427
  if params.pk_nonlin_type == "halofit" or params.pk_nonlin_type == "rev_halofit":
428
- assert (
429
- params.pk_type != "boltz"
430
- ), "Halofit model not supported by the Boltzmann solver yet!"
428
+ assert params.pk_type != "boltz", (
429
+ "Halofit model not supported by the Boltzmann solver yet!"
430
+ )
431
431
  from .NonLinearPerturbationHaloFit import NonLinearPerturbationHaloFit
432
432
 
433
433
  self.nonlin_pert = NonLinearPerturbationHaloFit(self)
434
434
 
435
435
  elif params.pk_nonlin_type == "mead":
436
- assert (
437
- params.pk_type != "boltz"
438
- ), "Mead model not supported by the Boltzmann solver yet!"
436
+ assert params.pk_type != "boltz", (
437
+ "Mead model not supported by the Boltzmann solver yet!"
438
+ )
439
439
  from .NonLinearPerturbationMead import NonLinearPerturbationMead
440
440
 
441
441
  self.nonlin_pert = NonLinearPerturbationMead(self)
442
442
 
443
443
  elif params.pk_nonlin_type == "HaloModel":
444
- assert (
445
- params.pk_type != "boltz"
446
- ), "HaloModel not supported by the Boltzmann solver yet!"
444
+ assert params.pk_type != "boltz", (
445
+ "HaloModel not supported by the Boltzmann solver yet!"
446
+ )
447
447
  from .NonLinearPerturbation_HaloModel import NonLinearPerturbation_HaloModel
448
448
 
449
449
  self.nonlin_pert = NonLinearPerturbation_HaloModel(self)
450
450
 
451
451
  elif params.pk_nonlin_type == "HI":
452
- assert (
453
- params.pk_type != "boltz"
454
- ), "HI not supported by the Boltzmann solver yet!"
452
+ assert params.pk_type != "boltz", (
453
+ "HI not supported by the Boltzmann solver yet!"
454
+ )
455
455
  from .NonLinearPerturbation_HI import NonLinearPerturbation_HI
456
456
 
457
457
  self.nonlin_pert = NonLinearPerturbation_HI(self)
@@ -16,6 +16,8 @@
16
16
 
17
17
  # pragma: no cover
18
18
 
19
+ # ruff: noqa
20
+
19
21
  import sympy as sp
20
22
  from sympy2c import (
21
23
  ERROR,
@@ -15,6 +15,9 @@
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
 
18
+ # pragma: no cover
19
+ # ruff: noqa
20
+
18
21
  import numpy as np
19
22
  import sympy as sp
20
23
  from sympy2c import (
@@ -14,6 +14,10 @@
14
14
  # You should have received a copy of the GNU General Public License along with this
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
+
18
+ # pragma: no cover
19
+ # ruff: noqa
20
+
17
21
  from CosmologyCore_massivenu import *
18
22
  from sympy2c import OdeCombined
19
23
 
@@ -14,6 +14,8 @@
14
14
  # You should have received a copy of the GNU General Public License along with this
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
+ # pragma: no cover
18
+ # ruff: noqa
17
19
 
18
20
  import numpy as np
19
21
  import sympy as sp
@@ -14,6 +14,9 @@
14
14
  # You should have received a copy of the GNU General Public License along with this
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
+ # pragma: no cover
18
+ # ruff: noqa
19
+
17
20
  from CosmologyCore_massivenu_wcdm import *
18
21
  from sympy2c import OdeCombined
19
22
 
@@ -15,6 +15,7 @@
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  # pragma: no cover
18
+ # ruff: noqa
18
19
 
19
20
  from CosmologyCore import *
20
21
  from sympy2c import OdeCombined
@@ -15,6 +15,7 @@
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  # pragma: no cover
18
+ # ruff: noqa
18
19
 
19
20
  import sympy as sp
20
21
  from sympy2c import (
@@ -15,6 +15,7 @@
15
15
  # program. If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
  # pragma: no cover
18
+ # ruff: noqa
18
19
 
19
20
  from CosmologyCore_wcdm import *
20
21
  from sympy2c import OdeCombined
@@ -169,9 +169,10 @@ class LinearPerturbationApprox(LinearPerturbationBase):
169
169
 
170
170
  _dlnh_dlna = self._background._dlnh_dlna(a=a_temp)[0]
171
171
 
172
- f2 = -(4.0 + _dlnh_dlna) * y[1] - (
173
- 3.0 + _dlnh_dlna - 1.5 * self._background._omega_m_a(a=a_temp)
174
- ) * y[0]
172
+ f2 = (
173
+ -(4.0 + _dlnh_dlna) * y[1]
174
+ - (3.0 + _dlnh_dlna - 1.5 * self._background._omega_m_a(a=a_temp)) * y[0]
175
+ )
175
176
  return [f1, f2]
176
177
 
177
178
  def _growth_derivs_nu(self, y, x):
@@ -186,9 +187,10 @@ class LinearPerturbationApprox(LinearPerturbationBase):
186
187
 
187
188
  _dlnh_dlna = self._background._dlnh_dlna_massive_nu(a=a_temp)
188
189
 
189
- f2 = -(4.0 + _dlnh_dlna) * y[1] - (
190
- 3.0 + _dlnh_dlna - 1.5 * self._background._omega_m_a(a=a_temp)
191
- ) * y[0]
190
+ f2 = (
191
+ -(4.0 + _dlnh_dlna) * y[1]
192
+ - (3.0 + _dlnh_dlna - 1.5 * self._background._omega_m_a(a=a_temp)) * y[0]
193
+ )
192
194
  return [f1, f2]
193
195
 
194
196
  def _growth_hyper_a(self, a=1.0): # , Om=0.25,z=0):
@@ -58,7 +58,7 @@ class LinearPerturbationBase(object):
58
58
  3.0 / (k * ri) ** 2 * (np.sin(k * ri) / (k * ri) - np.cos(k * ri))
59
59
  ) # top hat window function
60
60
  pk = self.powerspec_a_k(a=1.0, k=k)
61
- res[i] = np.trapz(k**3 * pk[0] * w**2, lnk)
61
+ res[i] = np.trapezoid(k**3 * pk[0] * w**2, lnk)
62
62
 
63
63
  return np.sqrt(1.0 / (2.0 * np.pi**2) * res)
64
64
 
@@ -107,7 +107,7 @@ class LinearPerturbationBase(object):
107
107
  return k**3 * w**2 * pk_interpolated(np.log(k))
108
108
 
109
109
  with warnings.catch_warnings():
110
- integral = np.trapz(integrand(k_fine), np.log(k_fine))
110
+ integral = np.trapezoid(integrand(k_fine), np.log(k_fine))
111
111
  res[i] = integral
112
112
 
113
113
  result = np.sqrt(1.0 / (2.0 * np.pi**2) * res)
@@ -116,16 +116,13 @@ class LinearPerturbationBase(object):
116
116
  return result
117
117
 
118
118
  @abc.abstractmethod
119
- def growth_a(self, a=1.0, k=None, norm=0, diag_only=True):
120
- ...
119
+ def growth_a(self, a=1.0, k=None, norm=0, diag_only=True): ...
121
120
 
122
121
  @abc.abstractmethod
123
- def transfer_k(self, k):
124
- ...
122
+ def transfer_k(self, k): ...
125
123
 
126
124
  @abc.abstractmethod
127
- def powerspec_a_k(self, a=1.0, k=0.1, diag_only=False):
128
- ...
125
+ def powerspec_a_k(self, a=1.0, k=0.1, diag_only=False): ...
129
126
 
130
127
  @abc.abstractmethod
131
128
  def max_redshift(self, k):
@@ -253,7 +253,7 @@ class NonLinearPerturbationHaloFit(NonLinearPerturbationBase):
253
253
 
254
254
  kseek = np.logspace(logkmin, logkmax, nk)
255
255
 
256
- sig2gauss = np.trapz(
256
+ sig2gauss = np.trapezoid(
257
257
  np.exp(-(np.outer(1 / kseek, k) ** 2)) * Dlin / k, x=k, axis=1
258
258
  )
259
259
 
@@ -272,14 +272,14 @@ class NonLinearPerturbationHaloFit(NonLinearPerturbationBase):
272
272
  # Effective index, equation (C7)
273
273
  # n = -3 - dlnsig^2/dlnR
274
274
  # = -3 + 2 int dlnk Dlin (k/ksig)^2 Wgauss(k/ksig) ** 2
275
- np3 = 2.0 * np.trapz(y**2 * np.exp(-(y**2)) * Dlin / k, x=k)
275
+ np3 = 2.0 * np.trapezoid(y**2 * np.exp(-(y**2)) * Dlin / k, x=k)
276
276
  # Spectral curvature, equation (C8)
277
277
  # C = - d^2lnsig^2/dlnR^2
278
278
  # = 2(n+3) + (n+3)^2 - 4 int dlnk Dlin (k/ksig)^4 Wgauss(k/ksig) ** 2
279
279
  C = (
280
280
  (np3 + 1.0) ** 2
281
281
  - 1.0
282
- - 4.0 * np.trapz(y**4 * np.exp(-(y**2)) * Dlin / k, x=k)
282
+ - 4.0 * np.trapezoid(y**4 * np.exp(-(y**2)) * Dlin / k, x=k)
283
283
  )
284
284
 
285
285
  return ksig, np3, C
@@ -304,12 +304,12 @@ class NonLinearPerturbationHaloFit(NonLinearPerturbationBase):
304
304
  # Effective index, equation (C7)
305
305
  # n = -3 - dlnsig^2/dlnR
306
306
  # = -3 + 2 int dlnk Dlin (k/ksig)^2 Wgauss(k/ksig) ** 2
307
- # np3 = 2*np.trapz(ysq*np.exp(-ysq)*Dlin/k,x=k)
307
+ # np3 = 2*np.trapezoid(ysq*np.exp(-ysq)*Dlin/k,x=k)
308
308
  n = np3 - 3.0
309
309
  # Spectral curvature, equation (C8)
310
310
  # C = - d^2lnsig^2/dlnR^2
311
311
  # = 2(n+3) + (n+3)^2 - 4 int dlnk Dlin (k/ksig)^4 Wgauss(k/ksig) ** 2
312
- # C = (np3+1) ** 2 - 1 - 4*np.trapz(ysq ** 2*np.exp(-ysq)*Dlin/k,x=k)
312
+ # C = (np3+1) ** 2 - 1 - 4*np.trapezoid(ysq ** 2*np.exp(-ysq)*Dlin/k,x=k)
313
313
 
314
314
  # omega_m_z dependent functions
315
315
  # 1st case: Matter dominated universe
@@ -447,7 +447,7 @@ class NonLinearPerturbationHaloFit(NonLinearPerturbationBase):
447
447
  :param Dlin: P(k) linear-theory matter power spectrum P(k) [Mpc^3]
448
448
  :return: 1D linear displacement variance, as defined in eq.4 in Mead et al, 2015
449
449
  """
450
- integr = 1.0 / 3 * np.trapz(Dlin / (k**3), x=k, axis=1)
450
+ integr = 1.0 / 3 * np.trapezoid(Dlin / (k**3), x=k, axis=1)
451
451
  sigmav = np.sqrt(integr)
452
452
  return np.sqrt(sigmav)
453
453
 
@@ -462,7 +462,7 @@ class NonLinearPerturbationHaloFit(NonLinearPerturbationBase):
462
462
  R = 100.0 / self._params.h
463
463
  T = 3 / ((k * R) ** 3) * (np.sin(k * R) - np.cos(k * R))
464
464
  # T = self.T(k * R)
465
- integr = 1.0 / 3 * np.trapz((Dlin / (k**3)) * (T**2), x=k, axis=1)
465
+ integr = 1.0 / 3 * np.trapezoid((Dlin / (k**3)) * (T**2), x=k, axis=1)
466
466
  sigma_d100 = np.sqrt(integr)
467
467
  return sigma_d100
468
468
 
@@ -480,7 +480,7 @@ class NonLinearPerturbationHaloFit(NonLinearPerturbationBase):
480
480
  w = (
481
481
  3 / ((k * R) ** 3) * (np.sin(k * R) - np.cos(k * R))
482
482
  ) # top hat window function
483
- res = np.trapz(k**3 * Dlin[0] * w**2, lnk)
483
+ res = np.trapezoid(k**3 * Dlin[0] * w**2, lnk)
484
484
  sig8z = np.sqrt(1.0 / (2.0 * np.pi**2) * res)
485
485
 
486
486
  return sig8z
@@ -382,8 +382,8 @@ class NonLinearPerturbationMead(NonLinearPerturbationBase):
382
382
  # n = -3 - dlnsig^2/dlnR|R=1/ksig
383
383
  # The division by sigma^2(1/ksig) is needed because sigma^2(1/ksig) is not 1
384
384
 
385
- i1 = np.trapz(Tksig * Tksig_deriv * Dlin, x=k_temp, axis=0)
386
- i2 = np.trapz(
385
+ i1 = np.trapezoid(Tksig * Tksig_deriv * Dlin, x=k_temp, axis=0)
386
+ i2 = np.trapezoid(
387
387
  self.T(1.0 / ksig * k_temp).T ** 2 * Dlin / k_temp[:, None],
388
388
  x=k_temp,
389
389
  axis=0,
@@ -409,7 +409,7 @@ class NonLinearPerturbationMead(NonLinearPerturbationBase):
409
409
  pklin = self._lin_pert.powerspec_a_k(k=k, a=a)
410
410
  Dlin = self._pk_to_D(pklin, k)
411
411
 
412
- res = np.trapz(Dlin / k[:, None] ** 3, k, axis=0)
412
+ res = np.trapezoid(Dlin / k[:, None] ** 3, k, axis=0)
413
413
  sigv = np.sqrt(res / 3.0)
414
414
  assert sigv.shape == (len(a),)
415
415
  return sigv
@@ -429,7 +429,7 @@ class NonLinearPerturbationMead(NonLinearPerturbationBase):
429
429
  Dlin = self._pk_to_D(pklin, k)
430
430
  T = self.T(k * R)
431
431
 
432
- res = np.trapz(T[:, None] ** 2 * Dlin / k[:, None] ** 3, x=k, axis=0)
432
+ res = np.trapezoid(T[:, None] ** 2 * Dlin / k[:, None] ** 3, x=k, axis=0)
433
433
 
434
434
  sigv = np.sqrt(res / 3.0)
435
435
  return sigv
@@ -450,7 +450,7 @@ class NonLinearPerturbationMead(NonLinearPerturbationBase):
450
450
 
451
451
  w = self.T(k * r) # top hat window function
452
452
  pk = self._lin_pert.powerspec_a_k(a=a, k=k)
453
- res = np.trapz(k[:, None] ** 3 * pk * w[:, None] ** 2, lnk, axis=0)
453
+ res = np.trapezoid(k[:, None] ** 3 * pk * w[:, None] ** 2, lnk, axis=0)
454
454
 
455
455
  sig8z = np.sqrt(1.0 / (2.0 * np.pi**2) * res)
456
456
  return sig8z
@@ -484,7 +484,7 @@ class NonLinearPerturbationMead(NonLinearPerturbationBase):
484
484
  assert t.shape == (nk, nm, na)
485
485
  integrand_mpc = ps * t**2.0 * k[:, None, None] ** 3.0
486
486
 
487
- integral = np.trapz(integrand_mpc, np.log(k), axis=0)
487
+ integral = np.trapezoid(integrand_mpc, np.log(k), axis=0)
488
488
 
489
489
  return integral.flatten()
490
490
 
@@ -853,5 +853,5 @@ def integral_halo(k, m_msun, nu_range, rv_mpc, c, a, f, eta):
853
853
  nufuncs = m_msun[:, None, :].T * nu_range[:, None, None] * f[:, None, None]
854
854
  u_km = _u_km_slow(k, a, c, rv_mpc, nu_range, eta)
855
855
  integrand_1halo = nufuncs * u_km**2.0
856
- integral_1halo = np.trapz(integrand_1halo, np.log(nu_range), axis=0)
856
+ integral_1halo = np.trapezoid(integrand_1halo, np.log(nu_range), axis=0)
857
857
  return integral_1halo
@@ -155,7 +155,7 @@ class NonLinearPerturbation_HI(NonLinearPerturbation_HaloModel):
155
155
  # corrections such that int(f dnu)=1. But just if we integrate below one solar mass.
156
156
  if self._params.min_halo_mass <= 1.0:
157
157
  delta_nu = nu_range[:, 1] - nu_range[:, 0]
158
- diff_f = 1 - np.trapz(f, nu_range)
158
+ diff_f = 1 - np.trapezoid(f, nu_range)
159
159
  const_f = diff_f / delta_nu * 2.0
160
160
  f[:, 0] += const_f
161
161
 
@@ -224,7 +224,7 @@ class NonLinearPerturbation_HI(NonLinearPerturbation_HaloModel):
224
224
  # corrections such that int(f dnu)=1. But just for if we integrate below one solar mass.
225
225
  if self._params.min_halo_mass <= 1.0:
226
226
  delta_nu = nu_range[:, 1] - nu_range[:, 0]
227
- diff_f = 1 - np.trapz(f, nu_range)
227
+ diff_f = 1 - np.trapezoid(f, nu_range)
228
228
  const_f = diff_f / delta_nu * 2.0
229
229
  f[:, 0] += const_f
230
230
 
@@ -305,11 +305,11 @@ class NonLinearPerturbation_HI(NonLinearPerturbation_HaloModel):
305
305
  # corrections such that int(f dnu)=1 and int(f*b dnu)=1. But just for if we integrate below one solar mass.
306
306
  if self._params.min_halo_mass <= 1.0:
307
307
  delta_nu = nu_range[:, 1] - nu_range[:, 0]
308
- diff_f = 1 - np.trapz(f, nu_range)
308
+ diff_f = 1 - np.trapezoid(f, nu_range)
309
309
  const_f = diff_f / delta_nu * 2.0
310
310
  f[:, 0] += const_f
311
311
 
312
- diff_bf = 1 - np.trapz(f * bias, nu_range)
312
+ diff_bf = 1 - np.trapezoid(f * bias, nu_range)
313
313
  const_b = diff_bf / (delta_nu * f[:, 0]) * 2.0
314
314
  bias[:, 0] += const_b
315
315