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: schechter_smf does not accept m_star and alpha as callable #523

Closed
philipp128 opened this issue Feb 24, 2022 · 1 comment · Fixed by #525
Closed

BUG: schechter_smf does not accept m_star and alpha as callable #523

philipp128 opened this issue Feb 24, 2022 · 1 comment · Fixed by #525
Assignees
Labels
bug Something isn't working module: galaxies

Comments

@philipp128
Copy link
Contributor

philipp128 commented Feb 24, 2022

Describe the bug
The method schechter_smf (here) in skypy.galaxies._schechter.py accepts the parameters m_star and 'alpha' as a callables.

However, an error is returned such that a callable is not accepted at the moment.

To Reproduce
Steps to reproduce the behavior:

  1. Run:
import numpy as np
from skypy.galaxies import schechter_smf
from astropy.cosmology import FlatLambdaCDM
from astropy.modeling.models import Linear1D, Exponential1D
from astropy.units import Quantity

redshift_range = [0,2]
m_min = 10**7
m_max = 10**14
cosmology = FlatLambdaCDM(H0=70, Om0=0.3)
sky_area = Quantity(1.27, "deg2")

phi_star = np.exp(-5.215 - 1.675 * 0)
M_star = Exponential1D(10**10.626, np.log(10)*1/0.095)
alpha = 0.357    ### no evolution allowed

redshift, mass = schechter_smf(redshift_range, M_star, phi_star, alpha, m_min, m_max, sky_area, cosmology)
  1. The following error is returned:
TypeError                                 Traceback (most recent call last)
<ipython-input-6-e4a8c8eb2786> in <module>
     26 
     27 print("Check M_star callable")
---> 28 redshift, mass = schechter_smf(redshift_range, M_star, phi_star, alpha, m_min, m_max, sky_area, cosmology)
     29 print(len(redshift))

/Applications/anaconda3/lib/python3.7/site-packages/astropy/units/decorators.py in wrapper(*func_args, **func_kwargs)
    232             # Call the original function with any equivalencies in force.
    233             with add_enabled_equivalencies(self.equivalencies):
--> 234                 return_ = wrapped_function(*func_args, **func_kwargs)
    235             if wrapped_signature.return_annotation not in (inspect.Signature.empty, None):
    236                 return return_.to(wrapped_signature.return_annotation)

/Applications/anaconda3/lib/python3.7/site-packages/skypy/galaxies/_schechter.py in schechter_smf(redshift, m_star, phi_star, alpha, m_min, m_max, sky_area, cosmology, noise)
    138 
    139     # sample galaxy mass for redshifts
--> 140     m = schechter_smf_mass(z, alpha, m_star, m_min, m_max)
    141 
    142     return z, m

/Applications/anaconda3/lib/python3.7/site-packages/skypy/galaxies/stellar_mass.py in schechter_smf_mass(redshift, alpha, m_star, m_min, m_max, size, resolution)
     68 
     69     # convert m_min, m_max to units of m_star
---> 70     x_min = m_min / m_star
     71     x_max = m_max / m_star
     72 

TypeError: unsupported operand type(s) for /: 'int' and 'Exponential1D'

Expected behavior
No error but the redshift z and mass m should be returned

Desktop (please complete the following information):

  • SkyPy version v0.5

Additional context
The problem is that the @dependent_argument decorator is missing. Compare to schechter_lf calling schechter_lf_magnitude (here)

@philipp128 philipp128 added bug Something isn't working module: galaxies labels Feb 24, 2022
@philipp128
Copy link
Contributor Author

philipp128 commented Feb 25, 2022

One should add decorator to schechter_smf_mass.

@philipp128 philipp128 self-assigned this Feb 25, 2022
@philipp128 philipp128 changed the title BUG: schechter_smf does not accept `m_star' as callable BUG: schechter_smf does not accept `m_star' and 'alpha' as callable Feb 25, 2022
@philipp128 philipp128 changed the title BUG: schechter_smf does not accept `m_star' and 'alpha' as callable BUG: schechter_smf does not accept m_star and alpha as callable Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module: galaxies
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant