Repository: scipy/scipy
File: scipy/stats/_distribution_infrastructure.py (Python)

Code before:

        Domain endpoints may be defined symbolically or through a callable.
        This returns numerical values of the endpoints given numerical values for
        any variables.

        Parameters
        ----------
        parameter_values : dict
            A dictionary that maps between string variable names and numerical
            values of parameters, which may define the endpoints.

        Returns
        -------
        a, b : ndarray
            Numerical values of the endpoints

        """
        # TODO: ensure outputs are floats
        a, b = self.endpoints
        try:
            if callable(a):
                a = a(**parameter_values)
            else:
                # If `a` (`b`) is a string - the name of the parameter that defines
                # the endpoint of the domain - then corresponding numerical values
                # will be found in the `parameter_values` dictionary.  Otherwise, it is
                # itself the array of numerical values of the endpoint.
                a = np.asarray(parameter_values.get(a, a))
            if callable(b):
                b = b(**parameter_values)
            else:
                b = np.asarray(parameter_values.get(b, b))
        except TypeError as e:
            message = ("The endpoints of the distribution are defined by "
                       "parameters, but their values were not provided. When "
                       f"using a private method of {self.__class__}, pass "
                       "all required distribution parameters as keyword "
                       "arguments.")
            raise TypeError(message) from e
        return a, b

    def contains(self, item, parameter_values=None):
        r"""Determine whether the argument is contained within the domain.

        Parameters
        ----------
        item : ndarray
            The argument
        parameter_values : dict
            A dictionary that maps between string variable names and numerical
            values of parameters, which may define the endpoints.

Review comment (suggestion):
```suggestion
        # If `a` (`b`) is a string - the name of the parameter that defines
        # the endpoint of the domain - then corresponding numerical values
        # will be found in the `parameter_values` dictionary. 
        # If a callable, it will be executed with `parameter_values` passed as
        # keyword arguments, and it will return the numerical values.
        # Otherwise, it is itself the array of numerical values of the endpoint.
        try:
```

Code after:

        Domain endpoints may be defined symbolically or through a callable.
        This returns numerical values of the endpoints given numerical values for
        any variables.

        Parameters
        ----------
        parameter_values : dict
            A dictionary that maps between string variable names and numerical
            values of parameters, which may define the endpoints.

        Returns
        -------
        a, b : ndarray
            Numerical values of the endpoints

        """
        # TODO: ensure outputs are floats
        a, b = self.endpoints
        # If `a` (`b`) is a string - the name of the parameter that defines
        # the endpoint of the domain - then corresponding numerical values
        # will be found in the `parameter_values` dictionary. 
        # If a callable, it will be executed with `parameter_values` passed as
        # keyword arguments, and it will return the numerical values.
        # Otherwise, it is itself the array of numerical values of the endpoint.
        try:
            if callable(a):
                a = a(**parameter_values)
            else:
                a = np.asarray(parameter_values.get(a, a))
            if callable(b):
                b = b(**parameter_values)
            else:
                b = np.asarray(parameter_values.get(b, b))
        except TypeError as e:
            message = ("The endpoints of the distribution are defined by "
                       "parameters, but their values were not provided. When "
                       f"using a private method of {self.__class__}, pass "
                       "all required distribution parameters as keyword "
                       "arguments.")
            raise TypeError(message) from e
        return a, b

    def contains(self, item, parameter_values=None):
        r"""Determine whether the argument is contained within the domain.

        Parameters
        ----------
        item : ndarray
            The argument
        parameter_values : dict