How to use the astromodels.SettingOutOfBounds function in astromodels

To help you get started, we’ve selected a few astromodels examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github threeML / threeML / threeML / minimizer / pyOpt_minimizer.py View on Github external
def __call__(self, x):

        new_args = map(lambda i: x[i], range(self._dimensions))

        try:

            f = self._function(*new_args)

        except SettingOutOfBounds:

            f = FIT_FAILED

        if f == FIT_FAILED:

            # Likelihood gave nan or other problems, we are likely in a forbidden
            # space

            fail = 1

        else:

            # Likelihood computation successful

            fail = 0
github threeML / threeML / threeML / utils / differentiation.py View on Github external
def wrapper(x):

        scaled_back_x = x * orders_of_magnitude  # type: np.ndarray

        try:

            result = function(*scaled_back_x)

        except SettingOutOfBounds:

            raise CannotComputeHessian(
                "Cannot compute Hessian, parameters out of bounds at %s" % scaled_back_x
            )

        else:

            return result