PyCosmo 2.2.0__tar.gz → 2.2.1__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 (124) hide show
  1. pycosmo-2.2.1/MANIFEST.in +1 -0
  2. pycosmo-2.2.1/PKG-INFO +55 -0
  3. pycosmo-2.2.1/README.md +19 -0
  4. pycosmo-2.2.1/pyproject.toml +113 -0
  5. pycosmo-2.2.1/setup.cfg +4 -0
  6. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/BoltzmannSolver/LinearPerturbationBoltzmann.py +4 -35
  7. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/BoltzmannSolver/ScipySolver.py +1 -1
  8. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore.py +2 -0
  9. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_massivenu.py +3 -0
  10. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_massivenu_rsa.py +4 -0
  11. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_massivenu_wcdm.py +2 -0
  12. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_massivenu_wcdm_rsa.py +3 -0
  13. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_rsa.py +1 -0
  14. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_wcdm.py +1 -0
  15. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/CosmologyCore_wcdm_rsa.py +1 -0
  16. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/LinearPerturbationApprox.py +8 -6
  17. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/LinearPerturbationBase.py +5 -8
  18. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/NonLinearPerturbationHaloFit.py +8 -8
  19. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/NonLinearPerturbationMead.py +7 -7
  20. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/NonLinearPerturbation_HI.py +4 -4
  21. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/NonLinearPerturbation_HaloModel.py +7 -7
  22. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/PerturbationTable.py +1 -1
  23. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/_RecombinationCosmics.py +3 -3
  24. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/__init__.py +10 -8
  25. pycosmo-2.2.1/src/PyCosmo/adaptive_simpson.c +7601 -0
  26. pycosmo-2.2.0/src/PyCosmo/Background.py → pycosmo-2.2.1/src/PyCosmo/background.py +4 -11
  27. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/__init__.py +0 -1
  28. pycosmo-2.2.0/src/PyCosmo/Cosmo.py → pycosmo-2.2.1/src/PyCosmo/cosmo.py +12 -12
  29. pycosmo-2.2.0/tests/test_pickling.py → pycosmo-2.2.1/src/PyCosmo/cython/__init__.py +9 -8
  30. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral.c +8190 -8081
  31. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_1h.c +8454 -8293
  32. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_2h.c +8884 -8737
  33. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_HI_1h.c +8976 -8845
  34. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_HI_2h.c +8735 -8601
  35. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/rho_HI_integral.c +8441 -8259
  36. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/rho_m_integral.c +8418 -8222
  37. pycosmo-2.2.0/src/PyCosmo/Obs.py → pycosmo-2.2.1/src/PyCosmo/obs.py +6 -6
  38. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/optimize_nq.py +2 -2
  39. pycosmo-2.2.0/src/PyCosmo/Projection.py → pycosmo-2.2.1/src/PyCosmo/projection.py +5 -5
  40. pycosmo-2.2.1/src/PyCosmo.egg-info/PKG-INFO +55 -0
  41. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo.egg-info/SOURCES.txt +8 -25
  42. pycosmo-2.2.1/src/PyCosmo.egg-info/requires.txt +10 -0
  43. pycosmo-2.2.0/PKG-INFO +0 -64
  44. pycosmo-2.2.0/README.rst +0 -18
  45. pycosmo-2.2.0/pyproject.toml +0 -45
  46. pycosmo-2.2.0/setup.cfg +0 -74
  47. pycosmo-2.2.0/src/PyCosmo/LinearPerturbationTable.py +0 -173
  48. pycosmo-2.2.0/src/PyCosmo/NonLinearPerturbationTable.py +0 -162
  49. pycosmo-2.2.0/src/PyCosmo/_Tables.py +0 -299
  50. pycosmo-2.2.0/src/PyCosmo/cython/__init__.py +0 -24
  51. pycosmo-2.2.0/src/PyCosmo.egg-info/PKG-INFO +0 -64
  52. pycosmo-2.2.0/src/PyCosmo.egg-info/requires.txt +0 -23
  53. pycosmo-2.2.0/tests/test_background.py +0 -410
  54. pycosmo-2.2.0/tests/test_boltzmann_solver.py +0 -831
  55. pycosmo-2.2.0/tests/test_class.py +0 -196
  56. pycosmo-2.2.0/tests/test_core_files_imports.py +0 -57
  57. pycosmo-2.2.0/tests/test_cosmo.py +0 -48
  58. pycosmo-2.2.0/tests/test_cython_extensions.py +0 -51
  59. pycosmo-2.2.0/tests/test_ini_handling.py +0 -45
  60. pycosmo-2.2.0/tests/test_linear_perturbation_approx.py +0 -256
  61. pycosmo-2.2.0/tests/test_massive_neutrinos.py +0 -172
  62. pycosmo-2.2.0/tests/test_nonlinear_perturbation_halofit.py +0 -129
  63. pycosmo-2.2.0/tests/test_nonlinear_perturbation_halomodel.py +0 -167
  64. pycosmo-2.2.0/tests/test_nonlinear_perturbation_mead.py +0 -216
  65. pycosmo-2.2.0/tests/test_obs.py +0 -822
  66. pycosmo-2.2.0/tests/test_perturbation_table.py +0 -84
  67. pycosmo-2.2.0/tests/test_pycosmo.py +0 -110
  68. pycosmo-2.2.0/tests/test_recombination.py +0 -19
  69. pycosmo-2.2.0/tests/test_scipy_solver.py +0 -91
  70. pycosmo-2.2.0/tests/test_util.py +0 -40
  71. {pycosmo-2.2.0 → pycosmo-2.2.1}/AUTHORS.rst +0 -0
  72. {pycosmo-2.2.0 → pycosmo-2.2.1}/LICENSE +0 -0
  73. {pycosmo-2.2.0 → pycosmo-2.2.1}/setup.py +0 -0
  74. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/BoltzmannSolver/Fields.py +0 -0
  75. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/BoltzmannSolver/LsodaSolver.py +0 -0
  76. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/BoltzmannSolver/__init__.py +0 -0
  77. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/PerturbationBase.py +0 -0
  78. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/TheoryPredTables.py +0 -0
  79. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/_Cosmics.py +0 -0
  80. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/_Recombination.py +0 -0
  81. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/_RecombinationClass.py +0 -0
  82. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/_Util.py +0 -0
  83. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/_scipy_utils.py +0 -0
  84. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/build.py +0 -0
  85. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_lcdm.ini +0 -0
  86. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_lcdm_rsa.ini +0 -0
  87. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_mnulcdm.ini +0 -0
  88. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_mnulcdm_rsa.ini +0 -0
  89. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_mnuwcdm.ini +0 -0
  90. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_mnuwcdm_rsa.ini +0 -0
  91. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_wcdm.ini +0 -0
  92. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/default_wcdm_rsa.ini +0 -0
  93. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/config/load_parameters_ini.py +0 -0
  94. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/core_file_handling.py +0 -0
  95. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/const.c +0 -0
  96. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/constf.c +0 -0
  97. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral.pyx +0 -0
  98. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_1h.pyx +0 -0
  99. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_2h.pyx +0 -0
  100. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_HI_1h.pyx +0 -0
  101. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/halo_integral_HI_2h.pyx +0 -0
  102. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/logf.c +0 -0
  103. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/main.c +0 -0
  104. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/mconf.h +0 -0
  105. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/mtherr.c +0 -0
  106. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/polevl.c +0 -0
  107. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/polevlf.c +0 -0
  108. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/protos.h +0 -0
  109. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/rho_HI_integral.pyx +0 -0
  110. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/rho_m_integral.pyx +0 -0
  111. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/sici.c +0 -0
  112. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/sici.h +0 -0
  113. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/sici32.c +0 -0
  114. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/sicif.c +0 -0
  115. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/cython/sinf.c +0 -0
  116. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/disable_multithreading.py +0 -0
  117. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/ini_handling.py +0 -0
  118. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/model_config.py +0 -0
  119. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/patches.py +0 -0
  120. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo/predefined_k_grids.py +0 -0
  121. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo.egg-info/dependency_links.txt +0 -0
  122. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo.egg-info/entry_points.txt +0 -0
  123. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo.egg-info/not-zip-safe +0 -0
  124. {pycosmo-2.2.0 → pycosmo-2.2.1}/src/PyCosmo.egg-info/top_level.txt +0 -0
@@ -0,0 +1 @@
1
+ prune tests
pycosmo-2.2.1/PKG-INFO ADDED
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: PyCosmo
3
+ Version: 2.2.1
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,113 @@
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.1"
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
+ ]
59
+
60
+ docs = [
61
+ "sphinx < 7",
62
+ "sphinx-pynpoint-theme",
63
+ "myst-parser",
64
+ ]
65
+
66
+ [project.scripts]
67
+ recompile = "PyCosmo:Cosmo.recompile_from_cli"
68
+
69
+ [tool.setuptools]
70
+ zip-safe = false
71
+ include-package-data = true
72
+
73
+ [tool.setuptools.package-data]
74
+ "*" = [
75
+ "*.pyx",
76
+ "*.c",
77
+ "*.h",
78
+ "config/*.ini",
79
+ ]
80
+
81
+
82
+ [tool.ruff]
83
+ line-length = 88
84
+ extend-exclude = ["benchmarks/", "*.ipynb"]
85
+
86
+ [tool.ruff.format]
87
+ quote-style = "double"
88
+ line-ending = "lf"
89
+ docstring-code-format = false
90
+
91
+ [tool.ruff.lint]
92
+ extend-select = [
93
+ "RUF100", # unnecessary `noqa` directives
94
+ ]
95
+ ignore = [
96
+ "E501",
97
+ "E731", # lambda assignment
98
+ "E741", # ambiguous variable name
99
+ ]
100
+
101
+ [tool.ruff.lint.per-file-ignores]
102
+ '__init__.py' = [
103
+ "F401", # imported but unused
104
+ ]
105
+
106
+
107
+ [tool.pytest.ini_options]
108
+ testpaths = ["tests"]
109
+ addopts = ["--verbose", "--durations=0", "--durations-min=5"]
110
+ markers = [
111
+ "slow: Marks tests as slow to run. Pass `--runslow` to include them."
112
+ ]
113
+ console_output_style = "count"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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
@@ -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
 
@@ -416,7 +416,7 @@ class NonLinearPerturbation_HaloModel(NonLinearPerturbationBase):
416
416
 
417
417
  w = self.T(k * r) # top hat window function
418
418
  pk = self._lin_pert.powerspec_a_k(a=a, k=k)
419
- res = np.trapz(k[:, None] ** 3 * pk * w[:, None] ** 2, lnk, axis=0)
419
+ res = np.trapezoid(k[:, None] ** 3 * pk * w[:, None] ** 2, lnk, axis=0)
420
420
 
421
421
  sig8z = np.sqrt(1.0 / (2.0 * np.pi**2) * res)
422
422
  return sig8z
@@ -453,7 +453,7 @@ class NonLinearPerturbation_HaloModel(NonLinearPerturbationBase):
453
453
  assert t.shape == (nk, nm, na)
454
454
  integrand_mpc = ps * t**2.0 * k[:, None, None] ** 3.0
455
455
 
456
- integral = np.trapz(integrand_mpc, np.log(k), axis=0)
456
+ integral = np.trapezoid(integrand_mpc, np.log(k), axis=0)
457
457
 
458
458
  return integral.flatten()
459
459
 
@@ -1031,7 +1031,7 @@ class NonLinearPerturbation_HaloModel(NonLinearPerturbationBase):
1031
1031
  # dnu)=1. But just if we integrate below one solar mass.
1032
1032
  if self._params.min_halo_mass <= 1.0:
1033
1033
  delta_nu = nu_range[:, 1] - nu_range[:, 0]
1034
- diff_f = 1 - np.trapz(f, nu_range)
1034
+ diff_f = 1 - np.trapezoid(f, nu_range)
1035
1035
  const_f = diff_f / delta_nu * 2.0
1036
1036
  f[:, 0] += const_f
1037
1037
 
@@ -1094,7 +1094,7 @@ class NonLinearPerturbation_HaloModel(NonLinearPerturbationBase):
1094
1094
  # dnu)=1. But just for if we integrate below one solar mass.
1095
1095
  if self._params.min_halo_mass <= 1.0:
1096
1096
  delta_nu = nu_range[:, 1] - nu_range[:, 0]
1097
- diff_f = 1 - np.trapz(f, nu_range)
1097
+ diff_f = 1 - np.trapezoid(f, nu_range)
1098
1098
  const_f = diff_f / delta_nu * 2.0
1099
1099
  f[:, 0] += const_f
1100
1100
 
@@ -1162,11 +1162,11 @@ class NonLinearPerturbation_HaloModel(NonLinearPerturbationBase):
1162
1162
  # corrections such that int(f dnu)=1 and int(f*b dnu)=1. But just for if we integrate below one solar mass.
1163
1163
  if self._params.min_halo_mass <= 1.0:
1164
1164
  delta_nu = nu_range[:, 1] - nu_range[:, 0]
1165
- diff_f = 1 - np.trapz(f, nu_range)
1165
+ diff_f = 1 - np.trapezoid(f, nu_range)
1166
1166
  const_f = diff_f / delta_nu * 2.0
1167
1167
  f[:, 0] += const_f
1168
1168
 
1169
- diff_bf = 1 - np.trapz(f * bias, nu_range)
1169
+ diff_bf = 1 - np.trapezoid(f * bias, nu_range)
1170
1170
  const_b = diff_bf / (delta_nu * f[:, 0]) * 2.0
1171
1171
  bias[:, 0] += const_b
1172
1172
 
@@ -1261,6 +1261,6 @@ class NonLinearPerturbation_HaloModel(NonLinearPerturbationBase):
1261
1261
  cosmo.nonlin_pert.print_params()
1262
1262
  """
1263
1263
 
1264
- print("The halomodel has been initialised with the" " following attributes:")
1264
+ print("The halomodel has been initialised with the following attributes:")
1265
1265
  for key in self._params.keys():
1266
1266
  print("{}={}".format(key, self._params[key]))
@@ -147,7 +147,7 @@ class PerturbationTable:
147
147
  if np.max(k_grid) < max_k:
148
148
  warnings.warn(
149
149
  f"ignore tabulation_max_k value {max_k} which is beyond the largest"
150
- " value {np.max(k_grid)} in the chosen k grid"
150
+ f" value {np.max(k_grid)} in the chosen k grid"
151
151
  )
152
152
 
153
153
  k_grid = k_grid[k_grid >= min_k]
@@ -35,9 +35,9 @@ class RecombinationCosmics:
35
35
  # call RECFAST++ to compute reionisation history tables
36
36
  print("Reading COSMICS recombination file")
37
37
 
38
- assert (
39
- self._params.recomb_filename is None
40
- ), "for cosmics setting the file name is not supported"
38
+ assert self._params.recomb_filename is None, (
39
+ "for cosmics setting the file name is not supported"
40
+ )
41
41
 
42
42
  tab_cosmics = cosmics(self._params.recomb_dir)
43
43