<commit_before>r"""
===============================================================================
Submodule -- Miscillaneous functions
===============================================================================

"""
import scipy as _sp
import scipy.stats as _spts


def random(N, seed=None, num_range=[0, 1], **kwargs):
    r"""
    Create an array of random numbers of a specified size.

    Parameters
    ----------
    N : int
        The length of the random array to be generated.  This should correspond
        to the number of pores or throats on the Geometry object.  For instance
        N = geom.Nt or N = geom.Np.

    seed : int
        The starting seed value to send to Scipy's random number generator.
        The default is None, which means different distribution is returned
        each time the model is run.

    num_range : list
        A two element list indicating the low and high end of the returned
        numbers.

    """
    range_size = num_range[1] - num_range[0]
    range_min = num_range[0]
    _sp.random.seed(seed)
    value = _sp.random.rand(N,)
    value = value*range_size + range_min
    return value


def weibull(geometry, shape, scale, loc, seeds, **kwargs):
    r"""
    Produces values from a Weibull distribution given a set of random numbers.

    Parameters
    ----------
    geometry : OpenPNM Geometry Object
        The object with which this function as associated.  This argument
        is required to (1) set number of values to generate (geom.Np or<commit_msg>Added a method to Geometry.models.misc for scaling an existing number by some factor.  Useful for constricting throat seeds or diameters.  This was needed for automated regeneration of properties.<commit_after>r"""
===============================================================================
Submodule -- Miscillaneous functions
===============================================================================

"""
import scipy as _sp
import scipy.stats as _spts


def random(N, seed=None, num_range=[0, 1], **kwargs):
    r"""
    Create an array of random numbers of a specified size.

    Parameters
    ----------
    N : int
        The length of the random array to be generated.  This should correspond
        to the number of pores or throats on the Geometry object.  For instance
        N = geom.Nt or N = geom.Np.

    seed : int
        The starting seed value to send to Scipy's random number generator.
        The default is None, which means different distribution is returned
        each time the model is run.

    num_range : list
        A two element list indicating the low and high end of the returned
        numbers.

    """
    range_size = num_range[1] - num_range[0]
    range_min = num_range[0]
    _sp.random.seed(seed)
    value = _sp.random.rand(N,)
    value = value*range_size + range_min
    return value


def scaled(geometry, prop, factor, **kwargs):
    r"""
    Scales an existing value by a factor.  Useful for constricting some throat
    property.

    Parameters
    ----------
    geometry : OpenPNM Geometry Object
        The object with which this function as associated.  This argument
        is required to (1) set number of values to generate (geom.Np or
        geom.Nt) and (2) provide access to other necessary values
        (i.e. geom['pore.seed']).

    prop : string
        The dictionary key of the array containing the values to be scaled.

    factor : scalar
        The factor by which the values should be scaled.
    """
    value = geometry[prop]*factor
    return value


def weibull(geometry, shape, scale, loc, seeds, **kwargs):
    r"""
    Produces values from a Weibull distribution given a set of random numbers.

    Parameters
    ----------
    geometry : OpenPNM Geometry Object
        The object with which this function as associated.  This argument
        is required to (1) set number of values to generate (geom.Np or
{'fraction_non_alphanumeric': 0.15077548944825833, 'fraction_numerical': 0.003559623696923468, 'mean_word_length': 2.800966183574879, 'pattern_counts': {'":': 0, '<': 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': '1858307', 'n_tokens_mistral': 1044, 'n_tokens_neox': 984, 'n_words': 446}