How to use the astromodels.utils.valid_variable.is_valid_variable_name 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 / plugins / SpectrumLike.py View on Github external
If either an SpectrumLike or XYLike instance is provided as background, it is assumed that this is the
        background data and the likelihood model from this plugin is used to simultaneously fit the background
        and source.

        :param name: the plugin name
        :param observation: the observed spectrum
        :param background: the background spectrum or a plugin from which the background will be modeled
        :param background_exposure: (optional) adjust the background exposure of the modeled background data comes from and
        XYLike plugin
        :param verbose: turn on/off verbose logging
        """

        # Just a toggle for verbosity
        self._verbose = bool(verbose)

        assert is_valid_variable_name(name), (
            "Name %s is not a valid name for a plugin. You must use a name which is "
            "a valid python identifier: no spaces, no operators (+,-,/,*), "
            "it cannot start with a number, no special characters" % name
        )

        assert isinstance(
            observation, BinnedSpectrum
        ), "The observed spectrum is not an instance of BinnedSpectrum"

        # Precomputed observed (for speed)

        self._observed_spectrum = observation  # type: BinnedSpectrum

        self._observed_counts = self._observed_spectrum.counts  # type: np.ndarray

        # initialize the background
github threeML / threeML / threeML / plugin_prototype.py View on Github external
def __init__(self, name, nuisance_parameters):
        assert is_valid_variable_name(name), (
            "The name %s cannot be used as a name. You need to use a valid "
            "python identifier: no spaces, cannot start with numbers, cannot contain "
            "operators symbols such as -, +, *, /" % name
        )

        # Make sure total is not used as a name (need to use it for other things, like the total value of the statistic)
        assert (
            name.lower() != "total"
        ), "Sorry, you cannot use 'total' as name for a plugin."

        self._name = name

        # This is just to make sure that the plugin is legal

        assert isinstance(nuisance_parameters, dict)
github threeML / threeML / threeML / io / plotting / plot_style.py View on Github external
def _check_name(name):

        if not is_valid_variable_name(name):
            raise NameError(
                "The name '%s' is not valid. Please use a simple name with no spaces nor "
                "special characters." % (name)
            )
github threeML / threeML / threeML / plugins / OGIPLike.py View on Github external
def __init__(
        self,
        name,
        observation,
        background=None,
        response=None,
        arf_file=None,
        spectrum_number=None,
        verbose=True,
    ):

        assert is_valid_variable_name(name), (
            "Name %s is not a valid name for a plugin. You must use a name which is "
            "a valid python identifier: no spaces, no operators (+,-,/,*), "
            "it cannot start with a number, no special characters" % name
        )

        # Read the pha file (or the PHAContainer instance)

        assert (
            isinstance(observation, str)
            or isinstance(observation, PHASpectrum)
            or isinstance(observation, PHAII)
        ), "observation must be a FITS file name or PHASpectrum"

        assert (
            isinstance(background, str)
            or isinstance(background, PHASpectrum)