archeo 2.0.0.dev4__tar.gz → 2.0.0.dev6__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 (61) hide show
  1. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/PKG-INFO +2 -1
  2. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/ancestral_posterior.py +5 -4
  3. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/__init__.py +1 -0
  4. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/bayes_factor_curve.py +3 -8
  5. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/resampler/base.py +3 -2
  6. archeo-2.0.0.dev6/archeo/constants/bayesian.py +3 -0
  7. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/constants/enum.py +10 -0
  8. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/bayesian/bayes_factor.py +5 -2
  9. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo.egg-info/PKG-INFO +2 -1
  10. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo.egg-info/SOURCES.txt +1 -0
  11. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo.egg-info/requires.txt +1 -0
  12. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/pyproject.toml +2 -1
  13. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/LICENSE +0 -0
  14. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/README.md +0 -0
  15. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/__init__.py +0 -0
  16. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/__main__.py +0 -0
  17. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/__init__.py +0 -0
  18. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/resampler/__init__.py +0 -0
  19. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/resampler/assume_independence.py +0 -0
  20. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/resampler/generic.py +0 -0
  21. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/bayesian/importance_sampling/resampler/interface.py +0 -0
  22. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/constants/__init__.py +0 -0
  23. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/constants/physics.py +0 -0
  24. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/__init__.py +0 -0
  25. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/annotation.py +0 -0
  26. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/distribution.py +0 -0
  27. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/math.py +0 -0
  28. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/physics/__init__.py +0 -0
  29. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/physics/binary.py +0 -0
  30. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/physics/black_hole.py +0 -0
  31. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/physics/mahapatra.py +0 -0
  32. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/physics/simulation.py +0 -0
  33. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/data_structures/visualization.py +0 -0
  34. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/postprocessing/__init__.py +0 -0
  35. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/postprocessing/dataframe.py +0 -0
  36. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/__init__.py +0 -0
  37. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/cli.py +0 -0
  38. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/forward/__init__.py +0 -0
  39. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/forward/compute_bayes_factor_curve.py +0 -0
  40. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/simulation/__init__.py +0 -0
  41. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/simulation/agnostic.py +0 -0
  42. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/simulation/n_generation.py +0 -0
  43. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/preset/simulation/second_generation.py +0 -0
  44. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/py.typed +0 -0
  45. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/simulation/__init__.py +0 -0
  46. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/simulation/simulate_merger.py +0 -0
  47. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/utils/__init__.py +0 -0
  48. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/utils/decorator.py +0 -0
  49. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/utils/env.py +0 -0
  50. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/utils/fs.py +0 -0
  51. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/utils/logger.py +0 -0
  52. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/utils/parallel.py +0 -0
  53. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/version.py +0 -0
  54. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/visualization/__init__.py +0 -0
  55. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/visualization/animation.py +0 -0
  56. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/visualization/base.py +0 -0
  57. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/visualization/distribution.py +0 -0
  58. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo/visualization/estimation.py +0 -0
  59. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo.egg-info/dependency_links.txt +0 -0
  60. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/archeo.egg-info/top_level.txt +0 -0
  61. {archeo-2.0.0.dev4 → archeo-2.0.0.dev6}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: archeo
3
- Version: 2.0.0.dev4
3
+ Version: 2.0.0.dev6
4
4
  Summary: Bayesian framework for inferring natal kick, ancestral masses and spins of black holes.
5
5
  Author-email: wyhwong <wyhwong@link.cuhk.edu.hk>
6
6
  License-Expression: MIT
@@ -32,6 +32,7 @@ Requires-Dist: scipy>=1.17.1
32
32
  Requires-Dist: seaborn>=0.13.2
33
33
  Requires-Dist: surfinbh>=1.2.7
34
34
  Requires-Dist: tabulate>=0.10.0
35
+ Requires-Dist: tenacity>=9.1.4
35
36
  Requires-Dist: tqdm>=4.67.3
36
37
  Dynamic: license-file
37
38
 
@@ -1,6 +1,7 @@
1
1
  import numpy as np
2
2
  import pandas as pd
3
3
 
4
+ from archeo.constants.bayesian import DEFAULT_BINSIZE_MASS, DEFAULT_BINSIZE_SPIN
4
5
  from archeo.utils.parallel import get_n_workers, multiprocess_run, multithread_run
5
6
 
6
7
 
@@ -8,8 +9,8 @@ def _retrieve_sample(
8
9
  df_binaries: pd.DataFrame,
9
10
  mass_measure: float,
10
11
  spin_measure: float,
11
- binsize_mass: float = 2.0,
12
- binsize_spin: float = 0.1,
12
+ binsize_mass: float = DEFAULT_BINSIZE_MASS,
13
+ binsize_spin: float = DEFAULT_BINSIZE_SPIN,
13
14
  ) -> pd.DataFrame:
14
15
  """Retrieve the samples from data frame of binaries"""
15
16
 
@@ -36,8 +37,8 @@ def infer_ancestral_posterior_distribution(
36
37
  df_binaries: pd.DataFrame,
37
38
  mass_posterior_samples: list[float],
38
39
  spin_posterior_samples: list[float],
39
- binsize_mass: float = 2.0,
40
- binsize_spin: float = 0.1,
40
+ binsize_mass: float = DEFAULT_BINSIZE_MASS,
41
+ binsize_spin: float = DEFAULT_BINSIZE_SPIN,
41
42
  random_state: int = 42,
42
43
  n_workers: int = 1,
43
44
  ) -> pd.DataFrame:
@@ -1,2 +1,3 @@
1
1
  from archeo.bayesian.importance_sampling.bayes_factor_curve import BayesFactorCurve, CandidatePrior
2
2
  from archeo.bayesian.importance_sampling.resampler.interface import ImportanceSamplingData
3
+ from archeo.data_structures.bayesian.bayes_factor import BayesFactorCurveMetadata
@@ -38,7 +38,7 @@ class CandidatePrior(BaseModel):
38
38
  df_bh1_prior = self.df_bh1.loc[self.df_bh1["v_esc"] <= v_esc]
39
39
  df_bh2_prior = self.df_bh2.loc[self.df_bh2["v_esc"] <= v_esc]
40
40
 
41
- if df_bh1_prior.empty and df_bh2_prior.empty:
41
+ if df_bh1_prior.empty or df_bh2_prior.empty:
42
42
  return pd.DataFrame(columns=self.df_bh1.columns.union(self.df_bh2.columns))
43
43
 
44
44
  n_samples = max(len(df_bh1_prior), len(df_bh2_prior), n_min)
@@ -57,14 +57,10 @@ class CandidatePrior(BaseModel):
57
57
  v_esc_max = max(self.df_bh1["v_esc"].max(), self.df_bh2["v_esc"].max())
58
58
 
59
59
  if log_scale:
60
- v_escs = np.logspace(np.log10(v_esc_min), np.log10(v_esc_max), n_pts)
60
+ v_escs = np.logspace(max(np.log10(v_esc_min), np.log10(0.1)), np.log10(v_esc_max), n_pts)
61
61
  else:
62
62
  v_escs = np.linspace(v_esc_min, v_esc_max, n_pts)
63
63
 
64
- # Add zero in the beginning of the list if it's not already included
65
- if v_escs[0] > 0:
66
- v_escs = np.insert(v_escs, 0, 0.0)
67
-
68
64
  # Add 5000 km/s in the end of the list if it's not already included
69
65
  if v_escs[-1] < 5000:
70
66
  v_escs = np.append(v_escs, 5000.0)
@@ -78,7 +74,6 @@ class BayesFactorCurve(BaseModel, frozen=True):
78
74
  n_bootstrapping: int = 50
79
75
  n_pts: int = 10
80
76
  log_scale: bool = False
81
- assume_parameter_independence: bool = False
82
77
  metadata: BayesFactorCurveMetadata = BayesFactorCurveMetadata()
83
78
 
84
79
  def _sample_bayes_factor(
@@ -95,7 +90,7 @@ class BayesFactorCurve(BaseModel, frozen=True):
95
90
  new_prior_samples=candidate_prior.get_conditional_prior(v_esc),
96
91
  binsize_spin=self.metadata.binsize_spin,
97
92
  binsize_mass=self.metadata.binsize_mass,
98
- assume_parameter_independence=self.assume_parameter_independence,
93
+ assume_parameter_independence=self.metadata.assume_parameter_independence,
99
94
  ).sample_bayes_factor(n=self.n_bootstrapping, is_parallel=True)
100
95
 
101
96
  @pre_release
@@ -2,6 +2,7 @@ import numpy as np
2
2
  import pandas as pd
3
3
  from pydantic import BaseModel, ConfigDict
4
4
 
5
+ from archeo.constants.bayesian import DEFAULT_BINSIZE_MASS, DEFAULT_BINSIZE_SPIN
5
6
  from archeo.data_structures.math import Domain
6
7
  from archeo.utils.logger import get_logger
7
8
 
@@ -17,8 +18,8 @@ class ImportanceSamplingDataBase(BaseModel, frozen=True):
17
18
  posterior_samples: pd.DataFrame
18
19
  prior_samples: pd.DataFrame
19
20
  new_prior_samples: pd.DataFrame
20
- binsize_spin: float = 0.05
21
- binsize_mass: float = 1.0
21
+ binsize_spin: float = DEFAULT_BINSIZE_SPIN
22
+ binsize_mass: float = DEFAULT_BINSIZE_MASS
22
23
  ztol: float = 1e-8
23
24
 
24
25
  @property
@@ -0,0 +1,3 @@
1
+ DEFAULT_BINSIZE_MASS = 2.0
2
+ DEFAULT_BINSIZE_SPIN = 0.1
3
+ ASSUME_PARAMETER_INDEPENDENCE = False
@@ -1,6 +1,8 @@
1
1
  import enum
2
2
  import os
3
3
 
4
+ from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed
5
+
4
6
  from archeo.utils.logger import get_logger
5
7
 
6
8
 
@@ -22,6 +24,11 @@ class Fits(enum.StrEnum):
22
24
  NRSUR7DQ4REMNANT = "NRSur7dq4Remnant"
23
25
  SURFINBH7DQ2 = "surfinBH7dq2"
24
26
 
27
+ @retry(
28
+ stop=stop_after_attempt(3),
29
+ wait=wait_fixed(3),
30
+ retry=retry_if_exception_type(RuntimeError),
31
+ )
25
32
  def load(self):
26
33
  """Load a surfinBH fits.
27
34
 
@@ -42,6 +49,9 @@ class Fits(enum.StrEnum):
42
49
  )
43
50
 
44
51
  try:
52
+ # NOTE: We added a retry logic because the model loading can fail
53
+ # due to IO limitation of h5py. This happens when we have multiple
54
+ # processes trying to load the same model at the same time.
45
55
  return surfinBH.LoadFits(self.value)
46
56
  except (OSError, KeyError) as e:
47
57
  LOGGER.error("Failed to load surfinBH %s: %s", self.value, str(e))
@@ -3,6 +3,8 @@ from typing import TypeAlias
3
3
  import numpy as np
4
4
  from pydantic import BaseModel, NonNegativeFloat
5
5
 
6
+ from archeo.constants.bayesian import ASSUME_PARAMETER_INDEPENDENCE, DEFAULT_BINSIZE_MASS, DEFAULT_BINSIZE_SPIN
7
+
6
8
 
7
9
  class BayesFactor(BaseModel, frozen=True):
8
10
  """Data class for Bayes factor with bootstrapping samples."""
@@ -33,5 +35,6 @@ class BayesFactorCurveMetadata(BaseModel, frozen=True):
33
35
 
34
36
  reference_candidate_name: str = "original"
35
37
  reference_bayes_factor: NonNegativeFloat = 1.0
36
- binsize_spin: float = 0.05
37
- binsize_mass: float = 1.0
38
+ binsize_spin: float = DEFAULT_BINSIZE_SPIN
39
+ binsize_mass: float = DEFAULT_BINSIZE_MASS
40
+ assume_parameter_independence: bool = ASSUME_PARAMETER_INDEPENDENCE
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: archeo
3
- Version: 2.0.0.dev4
3
+ Version: 2.0.0.dev6
4
4
  Summary: Bayesian framework for inferring natal kick, ancestral masses and spins of black holes.
5
5
  Author-email: wyhwong <wyhwong@link.cuhk.edu.hk>
6
6
  License-Expression: MIT
@@ -32,6 +32,7 @@ Requires-Dist: scipy>=1.17.1
32
32
  Requires-Dist: seaborn>=0.13.2
33
33
  Requires-Dist: surfinbh>=1.2.7
34
34
  Requires-Dist: tabulate>=0.10.0
35
+ Requires-Dist: tenacity>=9.1.4
35
36
  Requires-Dist: tqdm>=4.67.3
36
37
  Dynamic: license-file
37
38
 
@@ -20,6 +20,7 @@ archeo/bayesian/importance_sampling/resampler/base.py
20
20
  archeo/bayesian/importance_sampling/resampler/generic.py
21
21
  archeo/bayesian/importance_sampling/resampler/interface.py
22
22
  archeo/constants/__init__.py
23
+ archeo/constants/bayesian.py
23
24
  archeo/constants/enum.py
24
25
  archeo/constants/physics.py
25
26
  archeo/data_structures/__init__.py
@@ -10,4 +10,5 @@ scipy>=1.17.1
10
10
  seaborn>=0.13.2
11
11
  surfinbh>=1.2.7
12
12
  tabulate>=0.10.0
13
+ tenacity>=9.1.4
13
14
  tqdm>=4.67.3
@@ -16,7 +16,7 @@ classifiers = [
16
16
  "Operating System :: OS Independent"
17
17
  ]
18
18
  keywords = ["black-holes", "gravitational-waves", "black-hole-archeology"]
19
- version = "2.0.0.dev4"
19
+ version = "2.0.0.dev6"
20
20
  readme = "README.md"
21
21
  requires-python = ">=3.11,<3.14"
22
22
  dependencies = [
@@ -32,6 +32,7 @@ dependencies = [
32
32
  "seaborn>=0.13.2",
33
33
  "surfinbh>=1.2.7",
34
34
  "tabulate>=0.10.0",
35
+ "tenacity>=9.1.4",
35
36
  "tqdm>=4.67.3",
36
37
  ]
37
38
 
File without changes
File without changes
File without changes
File without changes