Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
* main:
  Update mmbulge test to use mamp_log10 (instead of deprecated mamp)
  Old parameter spaces use the 'mamp' parameter, which is now deprecated.  When it is used, emit a warning and convert the value, instead of raising an error
  Bump to v1.5.1
  • Loading branch information
lzkelley committed Apr 10, 2024
2 parents 47832c1 + 941c189 commit adb1ae3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 11 additions & 1 deletion holodeck/host_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,13 @@ def __init__(

# NOTE: manually catch deprecation [2024-04-06]
if 'mamp' in kwargs:
raise ValueError("The `mamp` parameter has been deprecated! Use `mamp_log10`!")
warn = "The `mamp` parameter has been deprecated! Use `mamp_log10`!"
log.warning(warn)
if mamp_log10 is not None:
err = "Both `mamp` (deprecated!) and `mamp_log10` have been given! Cannot correct."
log.exception(err)
raise ValueError(err)
mamp_log10 = np.log10(kwargs.pop('mamp') / MSOL)

# ---- Determine and set bulge fraction

Expand All @@ -695,6 +701,10 @@ def __init__(
self._mref = mref #: Reference Mass (argument normalization)
self._scatter_dex = scatter_dex

if len(kwargs) > 0:
warn = f"Unused parameters passed to {self}! {kwargs=}"
log.warning(warn)

return

def mbh_from_host(self, pop, scatter=None):
Expand Down
7 changes: 6 additions & 1 deletion holodeck/tests/test_host_relations__mmbulge.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,14 @@ def mbh_from_mbulge_KH2013(mbulge):
"""This is a manually-coded version of the TRUE [KH2013]_ relation to use for comparisons."""

# [KH2013] Eq. 10
AMP = 0.49 * (1e9 * MSOL)
# AMP = 0.49 * (1e9 * MSOL)
AMP_LOG10 = 8.69
PLAW = 1.17
# EPS = 0.28
X0 = 1e11 * MSOL

AMP = (10.0 ** AMP_LOG10) * MSOL

def func_KH2013(xx):
yy = AMP * np.power(xx/X0, PLAW)
return yy
Expand All @@ -209,9 +212,11 @@ class host:
vals = mmbulge_relation.mbh_from_host(host, scatter=False)
truth = truth_func(host.mbulge)

err = (vals - truth) / truth
print(f"mbulge [grams] = {host.mbulge}")
print(f"vals = {vals}")
print(f"truth = {truth}")
print(f"errors = {err}")
assert np.allclose(vals, truth)

# mbh ==> mbulge
Expand Down
2 changes: 1 addition & 1 deletion holodeck/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5
1.5.1

0 comments on commit adb1ae3

Please sign in to comment.