<commit_before>
import numpy as np
import scipy.special as sp
import sys
_allmodels = ["Zehavi05", "Zheng05", "Contreras"]

def get_hod(hod):
    """
    A function that chooses the correct Profile class and returns it
    """
    try:
        return getattr(sys.modules[__name__], hod)
    except AttributeError:
        raise
        raise AttributeError(str(hod) + "  is not a valid profile class")

class HOD(object):
    """
    Halo Occupation Distribution model base class.
    
    This class defines three methods -- the average central galaxies, average
    satellite galaxies and total galaxies. 
    
    The total number of galaxies can take two forms: one if there MUST be a
    central galaxy to have a satellite, and the other if not. 
    
    This class should not be called directly. The user
    should call a derived class.
    
    Derived classes of :class:`HOD` should define two methods: :method:`nc` and 
    :method:`ns` (central and satellite distributions respectively).
    Additionally, any parameters of the model should have their names and
    defaults defined as class variables. 
    
    The exception to this is the M_min parameter, which is defined for every
    model (it may still be defined to modify the default). This parameter acts
    as the one that may be set via the mean number density given all the other
    parameters. If the model has a sharp cutoff at low mass, corresponding to
    M_min, the extra parameter sharp_cut may be set to True, allowing for simpler
    setting of M_min via this route. 
    
    See the derived classes in this module for examples of how to define derived
    classes of :class:`HOD`.
    """
    _defaults = {"M_min": 11}
    sharp_cut = False

    def __init__(self, central=True, **model_parameters):
        for k in model_parameters:
            if k not in self._defaults:
                raise ValueError("%s is not a valid argument for the HOD" % k)

        self.params = self._defaults
        self.params.update(model_parameters)
        self._central = central

    def nc(self, M):
        pass

    def ns(self, M):
        pass

    def ntot(self, M):
        if self._central:
            return self.nc(M) * (1.0 + self.ns(M))
        else:
            return self.nc(M) + self.ns(M)

    @property
    def mmin(self):
        return self.params["M_min"]

class Zehavi05(HOD):
    """
    Three-parameter model of Zehavi (2005)
    
    Parameters
    ----------
    M_min : float, default = 11.6222
        Minimum mass of halo that supports a central galaxy
        
    M_1 : float, default = 12.851
        Mass of a halo which on average contains 1 satellite
        <commit_msg>fixed a problem where class variables would be updated erroneously<commit_after>
import numpy as np
import scipy.special as sp
import sys
import copy
_allmodels = ["Zehavi05", "Zheng05", "Contreras"]

def get_hod(hod):
    """
    A function that chooses the correct Profile class and returns it
    """
    try:
        return getattr(sys.modules[__name__], hod)
    except AttributeError:
        raise
        raise AttributeError(str(hod) + "  is not a valid profile class")

class HOD(object):
    """
    Halo Occupation Distribution model base class.
    
    This class defines three methods -- the average central galaxies, average
    satellite galaxies and total galaxies. 
    
    The total number of galaxies can take two forms: one if there MUST be a
    central galaxy to have a satellite, and the other if not. 
    
    This class should not be called directly. The user
    should call a derived class.
    
    Derived classes of :class:`HOD` should define two methods: :method:`nc` and 
    :method:`ns` (central and satellite distributions respectively).
    Additionally, any parameters of the model should have their names and
    defaults defined as class variables. 
    
    The exception to this is the M_min parameter, which is defined for every
    model (it may still be defined to modify the default). This parameter acts
    as the one that may be set via the mean number density given all the other
    parameters. If the model has a sharp cutoff at low mass, corresponding to
    M_min, the extra parameter sharp_cut may be set to True, allowing for simpler
    setting of M_min via this route. 
    
    See the derived classes in this module for examples of how to define derived
    classes of :class:`HOD`.
    """
    _defaults = {"M_min": 11}
    sharp_cut = False

    def __init__(self, central=True, **model_parameters):
        for k in model_parameters:
            if k not in self._defaults:
                raise ValueError("%s is not a valid argument for the HOD" % k)

        self.params = copy.copy(self._defaults)
        self.params.update(model_parameters)
        self._central = central

    def nc(self, M):
        pass

    def ns(self, M):
        pass

    def ntot(self, M):
        if self._central:
            return self.nc(M) * (1.0 + self.ns(M))
        else:
            return self.nc(M) + self.ns(M)

    @property
    def mmin(self):
        return self.params["M_min"]

class Zehavi05(HOD):
    """
    Three-parameter model of Zehavi (2005)
    
    Parameters
    ----------
    M_min : float, default = 11.6222
        Minimum mass of halo that supports a central galaxy
        
    M_1 : float, default = 12.851
        Mass of a halo which on average contains 1 satellite
        
{'fraction_non_alphanumeric': 0.0710613294160852, 'fraction_numerical': 0.009915534337128168, 'mean_word_length': 2.47163798597833, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3774281', 'n_tokens_mistral': 1546, 'n_tokens_neox': 1463, 'n_words': 659}