Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: Truncated Redshift distribution #59

Merged

Conversation

P-1884
Copy link
Contributor

@P-1884 P-1884 commented Jul 7, 2024

Fix for minor bug for the RedshiftsTruncNorm class

Description of Bug:
The lower source redshift truncation value (self.z_source_min) is updated dependent on the lens redshift, but is not reset to the default/inputted value after each draw. Therefore the truncation value gradually increases as more draws are made.
Fix:
The lower truncation value is now set to the inputted value (self.z_source_min_default) in the cases that it is greater than the lens redshift.

Copy link
Owner

@swagnercarena swagnercarena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Looks like a good change, but I suggested some small modification to the naming / use of self. properties.

@@ -338,7 +338,7 @@ def __init__(self, z_lens_min,z_lens_mean,z_lens_std,z_source_min,
z_source_mean,z_source_std):
# transform z_lens_min, z_source_min to be in units of std. deviations
self.z_lens_min = (z_lens_min - z_lens_mean) / z_lens_std
self.z_source_min = (z_source_min - z_source_mean) / z_source_std
self.z_source_min_default = (z_source_min - z_source_mean) / z_source_std
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would keep the original naming convention and instead change the object used in the call

@@ -355,8 +355,9 @@ def __call__(self):
z_lens = self.z_lens_dist()
clip = (z_lens - self.z_source_mean) / self.z_source_std
# number of std. devs away to stop (negative)
if(clip > self.z_source_min):
if(clip > self.z_source_min_default):
self.z_source_min = clip
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

z_source_min here instead of self.z_source_min would be a cleaner fix. In the current fix a new self.property is created during the call, which doesn't seem like optimal behavior since that property is never referenced outside the call.

@swagnercarena
Copy link
Owner

I think changing the naming as I suggested should fix the merge conflict, but we can take another look if it doesn't

@coveralls
Copy link

Coverage Status

coverage: 85.656% (-9.3%) from 94.973%
when pulling 66dc8c6 on P-1884:Truncated-redshift-distribution-fix
into 5405f4a on swagnercarena:main.

Copy link
Owner

@swagnercarena swagnercarena left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great!

@swagnercarena swagnercarena merged commit 3cebbd4 into swagnercarena:main Jul 9, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants