pybinny 1.2.0__tar.gz → 2.0.0__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 (156) hide show
  1. {pybinny-1.2.0/src/pybinny.egg-info → pybinny-2.0.0}/PKG-INFO +2 -2
  2. {pybinny-1.2.0 → pybinny-2.0.0}/pyproject.toml +3 -3
  3. pybinny-2.0.0/src/binny/__init__.py +21 -0
  4. pybinny-2.0.0/src/binny/analysis/__init__.py +123 -0
  5. {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/combinations.py +3 -0
  6. {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/comparison.py +1 -1
  7. {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/stats.py +13 -9
  8. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/__init__.py +27 -11
  9. pybinny-2.0.0/src/binny/binning/core.py +91 -0
  10. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/edges.py +0 -22
  11. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/photoz.py +1 -190
  12. pybinny-2.0.0/src/binny/binning/specz.py +538 -0
  13. pybinny-2.0.0/src/binny/calibration/__init__.py +43 -0
  14. {pybinny-1.2.0/src/binny/binning → pybinny-2.0.0/src/binny/calibration}/photoz_fitting.py +247 -10
  15. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/__init__.py +16 -34
  16. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/luminosity_function_distribution.py +2 -2
  17. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/models.py +3 -3
  18. pybinny-2.0.0/src/binny/nz/sampling.py +213 -0
  19. pybinny-2.0.0/src/binny/style/__init__.py +19 -0
  20. {pybinny-1.2.0/src/binny/utils → pybinny-2.0.0/src/binny/style}/colors.py +17 -18
  21. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/config_utils.py +1 -494
  22. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/euclid_survey_specs.yaml +1 -1
  23. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_full_specz.yaml +1 -1
  24. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/survey_presets.py +2 -1
  25. pybinny-2.0.0/src/binny/tomography/__init__.py +16 -0
  26. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/tomography/builders.py +13 -42
  27. pybinny-2.0.0/src/binny/tomography/core.py +297 -0
  28. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/tomography/predefined.py +23 -20
  29. pybinny-2.0.0/src/binny/tomography/specs.py +497 -0
  30. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/io.py +1 -1
  31. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/metadata.py +81 -14
  32. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/normalization.py +91 -51
  33. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/pairwise_metrics.py +1 -169
  34. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/types.py +2 -0
  35. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/validators.py +59 -0
  36. {pybinny-1.2.0 → pybinny-2.0.0/src/pybinny.egg-info}/PKG-INFO +2 -2
  37. {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/SOURCES.txt +30 -22
  38. pybinny-1.2.0/tests/test_tomography_combinations.py → pybinny-2.0.0/tests/test_analysis_combinations.py +8 -8
  39. pybinny-1.2.0/tests/test_tomography_comparison.py → pybinny-2.0.0/tests/test_analysis_comparison.py +1 -1
  40. pybinny-1.2.0/tests/test_tomography_comparison_helpers.py → pybinny-2.0.0/tests/test_analysis_comparison_helpers.py +2 -2
  41. pybinny-1.2.0/tests/test_tomography_comparison_similarity.py → pybinny-2.0.0/tests/test_analysis_comparison_similarity.py +1 -1
  42. pybinny-1.2.0/tests/test_tomography_composition.py → pybinny-2.0.0/tests/test_analysis_composition.py +1 -1
  43. pybinny-1.2.0/tests/test_tomography_stats.py → pybinny-2.0.0/tests/test_analysis_stats.py +32 -29
  44. pybinny-1.2.0/tests/test_tomography_stats_center_invariance_fast.py → pybinny-2.0.0/tests/test_analysis_stats_center_invariance_fast.py +2 -2
  45. pybinny-1.2.0/tests/test_tomography_stats_center_invariance_slow.py → pybinny-2.0.0/tests/test_analysis_stats_center_invariance_slow.py +2 -2
  46. pybinny-1.2.0/tests/test_tomography_stats_invariances.py → pybinny-2.0.0/tests/test_analysis_stats_invariances.py +14 -14
  47. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_mixed_edges_invariances_slow.py +1 -1
  48. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_core.py +2 -2
  49. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_edges.py +2 -2
  50. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_kernels.py +149 -150
  51. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_photoz_builder.py +192 -154
  52. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_specz.py +136 -21
  53. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_specz_builder.py +181 -185
  54. pybinny-1.2.0/tests/test_nz_calibration.py → pybinny-2.0.0/tests/test_calibration_depth.py +2 -2
  55. pybinny-2.0.0/tests/test_calibration_photoz_fitting.py +1050 -0
  56. pybinny-1.2.0/tests/test_nz_psf_selection.py → pybinny-2.0.0/tests/test_calibration_psf_selection.py +1 -1
  57. pybinny-2.0.0/tests/test_functional_binning_consistency.py +589 -0
  58. pybinny-2.0.0/tests/test_nz_sampling.py +588 -0
  59. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_predefined_api_consistency.py +2 -2
  60. pybinny-2.0.0/tests/test_public_api.py +190 -0
  61. pybinny-1.2.0/tests/test_utils_colors.py → pybinny-2.0.0/tests/test_style_colors.py +33 -33
  62. pybinny-2.0.0/tests/test_surveys_config_utils.py +428 -0
  63. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_surveys_survey_presets.py +4 -1
  64. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_surveys_tomography.py +25 -1
  65. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_builder.py +93 -11
  66. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_core.py +144 -35
  67. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_metadata_normalization.py +10 -9
  68. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_tomography_predefined.py +94 -13
  69. pybinny-1.2.0/tests/test_surveys_config_utils.py → pybinny-2.0.0/tests/test_tomography_specs.py +51 -438
  70. pybinny-2.0.0/tests/test_utils_metadata_arrays.py +61 -0
  71. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_normalization.py +151 -0
  72. pybinny-2.0.0/tests/test_utils_pairwise_metrics.py +127 -0
  73. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_validators.py +44 -0
  74. pybinny-1.2.0/src/binny/__init__.py +0 -45
  75. pybinny-1.2.0/src/binny/binning/core.py +0 -160
  76. pybinny-1.2.0/src/binny/binning/specz.py +0 -611
  77. pybinny-1.2.0/src/binny/tomography/__init__.py +0 -82
  78. pybinny-1.2.0/src/binny/tomography/core.py +0 -171
  79. pybinny-1.2.0/src/binny/tomography/metadata.py +0 -71
  80. pybinny-1.2.0/tests/test_binning_photoz_fitting.py +0 -449
  81. pybinny-1.2.0/tests/test_functional_binning_consistency.py +0 -109
  82. pybinny-1.2.0/tests/test_utils_pairwise_metrics.py +0 -300
  83. {pybinny-1.2.0 → pybinny-2.0.0}/LICENSE +0 -0
  84. {pybinny-1.2.0 → pybinny-2.0.0}/README.md +0 -0
  85. {pybinny-1.2.0 → pybinny-2.0.0}/setup.cfg +0 -0
  86. {pybinny-1.2.0/src/binny/tomography → pybinny-2.0.0/src/binny/analysis}/composition.py +0 -0
  87. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/__init__.py +0 -0
  88. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/bin_edges.py +0 -0
  89. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/grids.py +0 -0
  90. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/axes/mixed_edges.py +0 -0
  91. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/assignments.py +0 -0
  92. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/scheme_registry.py +0 -0
  93. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/binning/specs.py +0 -0
  94. pybinny-1.2.0/src/binny/nz/calibration.py → pybinny-2.0.0/src/binny/calibration/depth.py +0 -0
  95. {pybinny-1.2.0/src/binny/nz → pybinny-2.0.0/src/binny/calibration}/psf_selection.py +0 -0
  96. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/__init__.py +0 -0
  97. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/bin_combo_filter.py +0 -0
  98. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/filters.py +0 -0
  99. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/metrics.py +0 -0
  100. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/scores.py +0 -0
  101. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/correlations/topology.py +0 -0
  102. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/cosmology/__init__.py +0 -0
  103. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/cosmology/ccl_wrappers.py +0 -0
  104. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/nz/registry.py +0 -0
  105. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/__init__.py +0 -0
  106. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/__init__.py +0 -0
  107. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/des_survey_specs.yaml +0 -0
  108. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/desi_survey_specs.yaml +0 -0
  109. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_full_photoz.yaml +0 -0
  110. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_generalized_photoz.yaml +0 -0
  111. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_minimal_photoz.yaml +0 -0
  112. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_minimal_specz.yaml +0 -0
  113. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/example_tabulated.yaml +0 -0
  114. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/lsst_survey_specs.yaml +0 -0
  115. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/mock_predefined_config.yaml +0 -0
  116. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/configs/roman_survey_specs.yaml +0 -0
  117. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/__init__.py +0 -0
  118. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_bgs_sgc_nz.txt +0 -0
  119. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_elg_nz.txt +0 -0
  120. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_lrg_nz.txt +0 -0
  121. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/desi_lrg_sgc_nz.txt +0 -0
  122. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/example_tabulated_nz.txt +0 -0
  123. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/lsst_dp2_nz_degraded_r24p5_masked.txt +0 -0
  124. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/mock_predefined_bins.txt +0 -0
  125. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff20.nz +0 -0
  126. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff30.nz +0 -0
  127. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff40.nz +0 -0
  128. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/data/roman_n_eff50.nz +0 -0
  129. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/scripts/fit_roman_smail.py +0 -0
  130. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/surveys/sky.py +0 -0
  131. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/__init__.py +0 -0
  132. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/broadcasting.py +0 -0
  133. {pybinny-1.2.0 → pybinny-2.0.0}/src/binny/utils/relations.py +0 -0
  134. {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/dependency_links.txt +0 -0
  135. {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/requires.txt +1 -1
  136. {pybinny-1.2.0 → pybinny-2.0.0}/src/pybinny.egg-info/top_level.txt +0 -0
  137. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_bin_edges.py +0 -0
  138. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_grids.py +0 -0
  139. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_mixed_edges.py +0 -0
  140. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_axes_mixed_edges_invariances_fast.py +0 -0
  141. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_photoz.py +0 -0
  142. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_binning_scheme_registry.py +0 -0
  143. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_bin_combo_filter.py +0 -0
  144. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_filters.py +0 -0
  145. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_metrics.py +0 -0
  146. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_scores.py +0 -0
  147. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_correlations_topology.py +0 -0
  148. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_nz_luminosity_function_distribution.py +0 -0
  149. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_nz_models.py +0 -0
  150. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_nz_registry.py +0 -0
  151. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_surveys_sky.py +0 -0
  152. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_broadcasting.py +0 -0
  153. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_io.py +0 -0
  154. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_metadata.py +0 -0
  155. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_metadata_extended.py +0 -0
  156. {pybinny-1.2.0 → pybinny-2.0.0}/tests/test_utils_relations.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pybinny
3
- Version: 1.2.0
3
+ Version: 2.0.0
4
4
  Summary: Flexible tomographic binning algorithms for cosmology.
5
5
  Author-email: Nikolina Sarcevic <nikolina.sarcevic@gmail.com>
6
6
  License: MIT
@@ -10,7 +10,6 @@ License-File: LICENSE
10
10
  Requires-Dist: numpy
11
11
  Requires-Dist: pyyaml
12
12
  Requires-Dist: scipy
13
- Requires-Dist: cmasher
14
13
  Requires-Dist: matplotlib
15
14
  Requires-Dist: derivkit
16
15
  Provides-Extra: lf
@@ -29,6 +28,7 @@ Requires-Dist: tox>=4.22; extra == "dev"
29
28
  Requires-Dist: py-lfkit>=0.1.4; extra == "dev"
30
29
  Requires-Dist: pyccl>=3; extra == "dev"
31
30
  Provides-Extra: docs
31
+ Requires-Dist: cmasher; extra == "docs"
32
32
  Requires-Dist: sphinx[doctest]<9; extra == "docs"
33
33
  Requires-Dist: sphinx-copybutton; extra == "docs"
34
34
  Requires-Dist: sphinx-design; extra == "docs"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pybinny"
3
- version = "1.2.0"
3
+ version = "2.0.0"
4
4
  description = "Flexible tomographic binning algorithms for cosmology."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -11,7 +11,6 @@ dependencies = [
11
11
  "numpy",
12
12
  "pyyaml",
13
13
  "scipy",
14
- "cmasher",
15
14
  "matplotlib",
16
15
  "derivkit",
17
16
  ]
@@ -37,6 +36,7 @@ dev = [
37
36
  "pyccl>=3",
38
37
  ]
39
38
  docs = [
39
+ "cmasher",
40
40
  "sphinx[doctest]<9",
41
41
  "sphinx-copybutton",
42
42
  "sphinx-design",
@@ -102,7 +102,7 @@ where = ["src"]
102
102
  ]
103
103
 
104
104
  [tool.bumpversion]
105
- current_version = "1.2.0"
105
+ current_version = "2.0.0"
106
106
  commit = true
107
107
  tag = true
108
108
 
@@ -0,0 +1,21 @@
1
+ """Public Binny API."""
2
+
3
+ from binny import (
4
+ analysis,
5
+ binning,
6
+ calibration,
7
+ nz,
8
+ style,
9
+ surveys,
10
+ tomography,
11
+ )
12
+
13
+ __all__ = [
14
+ "analysis",
15
+ "binning",
16
+ "calibration",
17
+ "nz",
18
+ "style",
19
+ "surveys",
20
+ "tomography",
21
+ ]
@@ -0,0 +1,123 @@
1
+ """Scientific analysis, comparison, composition, and correlation filtering."""
2
+
3
+ from binny.analysis.combinations import make_bin_combo_filter
4
+ from binny.analysis.comparison import (
5
+ between_bin_overlap,
6
+ between_interval_mass_matrix,
7
+ between_overlap_pairs,
8
+ between_pearson_matrix,
9
+ bin_overlap,
10
+ leakage_matrix,
11
+ overlap_pairs,
12
+ pearson_matrix,
13
+ )
14
+ from binny.analysis.composition import (
15
+ align_bin_grids,
16
+ combine_parent_nz,
17
+ combine_tomographies,
18
+ interpolate_tomography,
19
+ sample_bin_labels,
20
+ sample_bins,
21
+ sample_combinations,
22
+ )
23
+ from binny.analysis.stats import (
24
+ bin_centers,
25
+ bin_moments,
26
+ bin_quantiles,
27
+ comoving_density_per_bin,
28
+ galaxy_count_per_bin,
29
+ galaxy_density_per_bin,
30
+ galaxy_fraction_per_bin,
31
+ in_range_fraction,
32
+ in_range_fraction_per_bin,
33
+ parent_stats,
34
+ peak_flags,
35
+ peak_flags_per_bin,
36
+ population_stats,
37
+ shape_stats,
38
+ )
39
+ from binny.correlations import (
40
+ BinComboFilter,
41
+ filter_by_curve_norm_threshold,
42
+ filter_by_metric_threshold,
43
+ filter_by_score_consistency,
44
+ filter_by_score_difference,
45
+ filter_by_score_relation,
46
+ filter_by_score_separation,
47
+ filter_by_width_ratio,
48
+ metric_from_curves,
49
+ metric_min_overlap_fraction,
50
+ metric_overlap_coefficient,
51
+ pairs_all,
52
+ pairs_cartesian,
53
+ pairs_diagonal,
54
+ pairs_lower_triangle,
55
+ pairs_off_diagonal,
56
+ pairs_upper_triangle,
57
+ score_credible_width,
58
+ score_mean_location,
59
+ score_median_location,
60
+ score_peak_location,
61
+ tuples_all,
62
+ tuples_cartesian,
63
+ tuples_diagonal,
64
+ tuples_nondecreasing,
65
+ )
66
+
67
+ __all__ = [
68
+ "BinComboFilter",
69
+ "align_bin_grids",
70
+ "between_bin_overlap",
71
+ "between_interval_mass_matrix",
72
+ "between_overlap_pairs",
73
+ "between_pearson_matrix",
74
+ "bin_centers",
75
+ "bin_moments",
76
+ "bin_overlap",
77
+ "bin_quantiles",
78
+ "combine_parent_nz",
79
+ "combine_tomographies",
80
+ "comoving_density_per_bin",
81
+ "filter_by_curve_norm_threshold",
82
+ "filter_by_metric_threshold",
83
+ "filter_by_score_consistency",
84
+ "filter_by_score_difference",
85
+ "filter_by_score_relation",
86
+ "filter_by_score_separation",
87
+ "filter_by_width_ratio",
88
+ "galaxy_count_per_bin",
89
+ "galaxy_density_per_bin",
90
+ "galaxy_fraction_per_bin",
91
+ "in_range_fraction",
92
+ "in_range_fraction_per_bin",
93
+ "interpolate_tomography",
94
+ "leakage_matrix",
95
+ "make_bin_combo_filter",
96
+ "metric_from_curves",
97
+ "metric_min_overlap_fraction",
98
+ "metric_overlap_coefficient",
99
+ "overlap_pairs",
100
+ "pairs_all",
101
+ "pairs_cartesian",
102
+ "pairs_diagonal",
103
+ "pairs_lower_triangle",
104
+ "pairs_off_diagonal",
105
+ "pairs_upper_triangle",
106
+ "parent_stats",
107
+ "peak_flags",
108
+ "peak_flags_per_bin",
109
+ "pearson_matrix",
110
+ "population_stats",
111
+ "sample_bin_labels",
112
+ "sample_bins",
113
+ "sample_combinations",
114
+ "score_credible_width",
115
+ "score_mean_location",
116
+ "score_median_location",
117
+ "score_peak_location",
118
+ "shape_stats",
119
+ "tuples_all",
120
+ "tuples_cartesian",
121
+ "tuples_diagonal",
122
+ "tuples_nondecreasing",
123
+ ]
@@ -30,3 +30,6 @@ def make_bin_combo_filter(
30
30
  }
31
31
 
32
32
  return BinComboFilter(z=z_common, curves=[bins_a, bins_b])
33
+
34
+
35
+ __all__ = ["make_bin_combo_filter"]
@@ -7,7 +7,7 @@ from typing import Any, Literal
7
7
 
8
8
  import numpy as np
9
9
 
10
- from binny.tomography.composition import align_bin_grids
10
+ from binny.analysis.composition import align_bin_grids
11
11
  from binny.utils.metadata import round_floats
12
12
  from binny.utils.normalization import (
13
13
  normalize_edges,
@@ -413,18 +413,22 @@ def peak_flags_per_bin(
413
413
 
414
414
  def galaxy_fraction_per_bin(meta: Mapping[str, Any]) -> dict[int, float]:
415
415
  """Extract and normalize per-bin population fractions from tomo metadata."""
416
- frac = meta.get("frac_per_bin", None)
416
+ bins_meta = meta.get("bins")
417
417
 
418
- if frac is None and isinstance(meta.get("bins"), Mapping):
419
- frac = meta["bins"].get("frac_per_bin", None)
418
+ if not isinstance(bins_meta, Mapping):
419
+ raise ValueError("metadata must contain a mapping 'bins'.")
420
420
 
421
- if frac is None or not isinstance(frac, Mapping):
422
- raise ValueError("metadata must contain a mapping 'frac_per_bin'.")
421
+ frac = bins_meta.get("frac_per_bin")
422
+
423
+ if not isinstance(frac, Mapping):
424
+ raise ValueError("metadata must contain a mapping 'bins.frac_per_bin'.")
423
425
 
424
426
  out: dict[int, float] = {int(k): float(v) for k, v in frac.items()}
425
427
  s = float(sum(out.values()))
428
+
426
429
  if s <= 0.0:
427
430
  raise ValueError("Sum of metadata frac_per_bin must be positive.")
431
+
428
432
  return {i: f / s for i, f in out.items()}
429
433
 
430
434
 
@@ -470,7 +474,7 @@ def galaxy_density_per_bin(
470
474
  effective density..
471
475
 
472
476
  Args:
473
- metadata: Tomography metadata containing ``"frac_per_bin"``.
477
+ metadata: Tomography metadata containing ``metadata["bins"]["frac_per_bin"]``.
474
478
  density_total: Total effective surface density (gal/arcmin^2).
475
479
 
476
480
  Returns:
@@ -630,7 +634,7 @@ def population_stats(
630
634
  This function computes quantities that depend on relative bin populations,
631
635
  using metadata produced by Binny's tomo builders.
632
636
 
633
- The primary input is ``metadata["frac_per_bin"]`` (mapping bin index to
637
+ The primary input is ``metadata["bins"]["frac_per_bin"]`` (mapping bin index to
634
638
  fraction). Fractions are checked against the bin indices present in
635
639
  ``bins``.
636
640
 
@@ -645,7 +649,7 @@ def population_stats(
645
649
 
646
650
  Args:
647
651
  bins: Mapping from bin index to bin curves.
648
- metadata: Tomography metadata containing ``"frac_per_bin"``.
652
+ metadata: Tomography metadata containing ``metadata["bins"]["frac_per_bin"]``.
649
653
  density_total: Optional total effective surface density in
650
654
  galaxies per square arcminute.
651
655
  survey_area: Optional survey area in square arcminutes. Requires
@@ -670,7 +674,7 @@ def population_stats(
670
674
 
671
675
  Raises:
672
676
  ValueError: If bins is empty.
673
- ValueError: If metadata does not contain ``"frac_per_bin"``.
677
+ ValueError: If metadata does not contain valid per-bin population fractions.
674
678
  ValueError: If metadata fractions are missing any bin index.
675
679
  ValueError: If ``survey_area`` is provided without ``density_total``.
676
680
  ValueError: If only one of ``total_count_per_bin`` and
@@ -1,5 +1,18 @@
1
- """Binning, assignment models, and redshift-error calibration."""
1
+ """Bin-edge construction, binning schemes, and assignment models."""
2
2
 
3
+ from binny.axes import (
4
+ chebyshev_edges,
5
+ equal_information_edges,
6
+ equal_number_edges,
7
+ equidistant_chi_edges,
8
+ equidistant_edges,
9
+ generalized_tomographic_edges,
10
+ geometric_edges,
11
+ log_edges,
12
+ mixed_edges,
13
+ power_edges,
14
+ sinh_edges,
15
+ )
3
16
  from binny.binning.assignments import (
4
17
  deterministic_assignment,
5
18
  specz_selection_in_bin,
@@ -12,15 +25,10 @@ from binny.binning.edges import (
12
25
  validate_bin_edges,
13
26
  )
14
27
  from binny.binning.photoz import (
15
- build_photoz_bins,
16
28
  photoz_assignment,
17
29
  photoz_assignment_probability,
18
30
  true_redshift_distribution,
19
31
  )
20
- from binny.binning.photoz_fitting import (
21
- fit_photoz_errors,
22
- to_binny_photoz_params,
23
- )
24
32
  from binny.binning.scheme_registry import (
25
33
  available_binning_schemes,
26
34
  get_binning_scheme,
@@ -28,32 +36,40 @@ from binny.binning.scheme_registry import (
28
36
  )
29
37
  from binny.binning.specz import (
30
38
  apply_response_matrix,
31
- build_specz_bins,
32
39
  build_specz_response_matrix,
33
40
  specz_assignment,
34
41
  specz_gaussian_response_matrix,
35
42
  )
43
+ from binny.utils.io import load_binning_recipe
36
44
 
37
45
  __all__ = [
38
46
  "apply_response_matrix",
39
47
  "available_binning_schemes",
40
48
  "build_bins",
41
- "build_photoz_bins",
42
- "build_specz_bins",
43
49
  "build_specz_response_matrix",
50
+ "chebyshev_edges",
44
51
  "deterministic_assignment",
45
- "fit_photoz_errors",
52
+ "equal_information_edges",
53
+ "equal_number_edges",
54
+ "equidistant_chi_edges",
55
+ "equidistant_edges",
56
+ "generalized_tomographic_edges",
57
+ "geometric_edges",
46
58
  "get_binning_scheme",
59
+ "load_binning_recipe",
60
+ "log_edges",
61
+ "mixed_edges",
47
62
  "mixed_edges_from_segments",
48
63
  "photoz_assignment",
49
64
  "photoz_assignment_probability",
65
+ "power_edges",
50
66
  "register_binning_scheme",
51
67
  "resolve_bin_edges",
52
68
  "segments_to_axes",
69
+ "sinh_edges",
53
70
  "specz_assignment",
54
71
  "specz_gaussian_response_matrix",
55
72
  "specz_selection_in_bin",
56
- "to_binny_photoz_params",
57
73
  "true_redshift_distribution",
58
74
  "validate_bin_edges",
59
75
  ]
@@ -0,0 +1,91 @@
1
+ """Generic selection-based tomographic binning."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from collections.abc import Callable
6
+ from typing import Literal
7
+
8
+ import numpy as np
9
+
10
+ from binny.binning.edges import validate_bin_edges
11
+ from binny.utils.normalization import integrate_1d
12
+ from binny.utils.types import FloatArray
13
+ from binny.utils.validators import validate_axis_and_weights
14
+
15
+ __all__ = ["build_bins"]
16
+
17
+
18
+ def build_bins(
19
+ z: FloatArray,
20
+ nz: FloatArray,
21
+ edges: FloatArray,
22
+ assignment: Callable[[FloatArray, FloatArray], FloatArray],
23
+ *,
24
+ selection_kind: Literal["probability", "weight"] = "probability",
25
+ normalize_bins: bool = False,
26
+ norm_method: Literal["trapezoid", "simpson"] = "trapezoid",
27
+ return_integrals: bool = False,
28
+ ) -> dict[int, FloatArray] | tuple[dict[int, FloatArray], dict[int, float], float]:
29
+ """Build tomographic bins using a selection function.
30
+
31
+ Args:
32
+ z: Parent redshift grid.
33
+ nz: Parent redshift distribution.
34
+ edges: Bin edges in the selection coordinate.
35
+ assignment: Function returning selections of shape
36
+ ``(n_bins, n_z)``.
37
+ selection_kind: Whether selections are probabilities in
38
+ ``[0, 1]`` or non-negative weights.
39
+ normalize_bins: Whether to normalize each bin.
40
+ norm_method: Integration method for normalization and population integrals.
41
+ return_integrals: Whether to return raw bin integrals
42
+ and the parent integral.
43
+
44
+ Returns:
45
+ Dictionary of bin distributions, optionally accompanied
46
+ by bin integrals and the parent integral.
47
+
48
+ Raises:
49
+ ValueError: If the selection type, shape, or values are invalid.
50
+ """
51
+ z_arr, nz_arr = validate_axis_and_weights(z, nz)
52
+ edges_arr = validate_bin_edges(edges)
53
+
54
+ if selection_kind not in {"probability", "weight"}:
55
+ raise ValueError("selection_kind must be 'probability' or 'weight'.")
56
+
57
+ selection = np.asarray(assignment(z_arr, edges_arr), dtype=np.float64)
58
+ expected_shape = (edges_arr.size - 1, z_arr.size)
59
+
60
+ if selection.shape != expected_shape:
61
+ raise ValueError(f"assignment returned shape {selection.shape}, expected {expected_shape}.")
62
+
63
+ if not np.all(np.isfinite(selection)):
64
+ raise ValueError("Selection values must be finite.")
65
+
66
+ if np.any(selection < 0.0):
67
+ raise ValueError("Selection values must be non-negative.")
68
+
69
+ if selection_kind == "probability" and np.any(selection > 1.0):
70
+ raise ValueError("Selection probabilities must not exceed 1.")
71
+
72
+ bins: dict[int, FloatArray] = {}
73
+ bin_integrals: dict[int, float] = {}
74
+
75
+ for i, probability in enumerate(selection):
76
+ raw = nz_arr * probability
77
+ area = integrate_1d(z_arr, raw, method=norm_method)
78
+
79
+ if return_integrals:
80
+ bin_integrals[i] = area
81
+
82
+ if normalize_bins and area > 0.0:
83
+ raw = raw / area
84
+
85
+ bins[i] = raw
86
+
87
+ if return_integrals:
88
+ parent_integral = integrate_1d(z_arr, nz_arr, method=norm_method)
89
+ return bins, bin_integrals, parent_integral
90
+
91
+ return bins
@@ -36,7 +36,6 @@ __all__ = [
36
36
  "resolve_bin_edges",
37
37
  "validate_bin_edges",
38
38
  "segments_to_axes",
39
- "photoz_segments_to_axes",
40
39
  "mixed_edges_from_segments",
41
40
  ]
42
41
 
@@ -510,27 +509,6 @@ def segments_to_axes(
510
509
  return result
511
510
 
512
511
 
513
- def photoz_segments_to_axes(
514
- segments: Sequence[Mapping[str, Any]],
515
- ) -> list[dict[str, Any]]:
516
- """Convert legacy photo-z segments to generic axis descriptions.
517
-
518
- This compatibility function accepts the same segment specifications
519
- as :func:`segments_to_axes`. New code should call that function
520
- directly.
521
-
522
- Args:
523
- segments: Ordered segment specifications.
524
-
525
- Returns:
526
- List of generic axis-level segment descriptions.
527
-
528
- Raises:
529
- ValueError: If a segment specification is invalid.
530
- """
531
- return segments_to_axes(segments)
532
-
533
-
534
512
  def mixed_edges_from_segments(
535
513
  segments: Sequence[Mapping[str, Any]],
536
514
  *,