# Path: sherpa_contrib/utils.py
# def _is_boolean(val):
#     def __str__(self):
#         def fmt(key, val):
#     def __init__(self, id=None, fluxtype="photon"):
#     def _calc_bins(self, data):
#     def _apply_mask(self, data):
#     def save(self, filename, clobber=True):
#     def plot(self, overplot=False, clearwindow=True, **kwargs):
#     def _estimate_expmap(self, *args):
#     def estimate_expmap(self, *args):
#     def _calc_bins(self, data):
#     def _calc_bins(self, data):
#     def estimate_expmap(self, *args):
# def get_instmap_weights(id=None, fluxtype="photon"):
# def save_instmap_weights(*args, **kwargs):
# def plot_instmap_weights(id=None, fluxtype="photon",
#                          overplot=False, clearwindow=True, **kwargs):
# def estimate_weighted_expmap(id=None, arf=None, elo=None, ehi=None,
#                              specresp=None, fluxtype="photon",
#                              par=None, pvals=None):
# def renorm(id=None, cpt=None, bkg_id=None, names=None,
#            limscale=10000.0):
# class InstMapWeights:
# class InstMapWeights1DInt(InstMapWeights):
# class InstMapWeightsPHA(InstMapWeights):


import unittest
import numpy as np
import sys
from sherpa.astro import ui
from sherpa.utils.err import IdentifierErr
from sherpa_contrib import utils
        ui.set_source("tst", ui.powlaw1d.pltst)

        # when gamma=0, weight is the same for each bin (when equally
        # spaced)
        pl1.gamma = 0.0
        pl1.ampl = 1.2
        pltst.gamma = -1.0
        pltst.ampl = 2.1

        arfgrid = np.arange(0.5, 5, 0.02)
        self.arflo = arfgrid[:-1]
        self.arfhi = arfgrid[1:]
        self.flatarf = self.arflo * 0 + 10.1
        amid = (self.arflo + self.arfhi) / 2.0
        self.arf = 10 - (3.0 - amid)**2

    def tearDown(self):
        # there's an issue in CIAO 4.8 with delete_model and
        # delete_model_component, so just call clean
        """
        for idval in [1, "tst"]:
            ui.delete_model(id=idval)
            ui.delete_model_component("pl{}".format(idval))
            ui.delete_data(id=idval)

        ui.delete_data(id="not-used")
        """
        ui.clean()

    def test_invalid_id(self):

# Path: sherpa_contrib/utils.py
# def _is_boolean(val):
#     def __str__(self):
#         def fmt(key, val):
#     def __init__(self, id=None, fluxtype="photon"):
#     def _calc_bins(self, data):
#     def _apply_mask(self, data):
#     def save(self, filename, clobber=True):
#     def plot(self, overplot=False, clearwindow=True, **kwargs):
#     def _estimate_expmap(self, *args):
#     def estimate_expmap(self, *args):
#     def _calc_bins(self, data):
#     def _calc_bins(self, data):
#     def estimate_expmap(self, *args):
# def get_instmap_weights(id=None, fluxtype="photon"):
# def save_instmap_weights(*args, **kwargs):
# def plot_instmap_weights(id=None, fluxtype="photon",
#                          overplot=False, clearwindow=True, **kwargs):
# def estimate_weighted_expmap(id=None, arf=None, elo=None, ehi=None,
#                              specresp=None, fluxtype="photon",
#                              par=None, pvals=None):
# def renorm(id=None, cpt=None, bkg_id=None, names=None,
#            limscale=10000.0):
# class InstMapWeights:
# class InstMapWeights1DInt(InstMapWeights):
# class InstMapWeightsPHA(InstMapWeights):


# Path: sherpa_contrib/tests/test_weights.py
import unittest
import numpy as np
import sys
from sherpa.astro import ui
from sherpa.utils.err import IdentifierErr
from sherpa_contrib import utils

        ui.set_source("tst", ui.powlaw1d.pltst)

        # when gamma=0, weight is the same for each bin (when equally
        # spaced)
        pl1.gamma = 0.0
        pl1.ampl = 1.2
        pltst.gamma = -1.0
        pltst.ampl = 2.1

        arfgrid = np.arange(0.5, 5, 0.02)
        self.arflo = arfgrid[:-1]
        self.arfhi = arfgrid[1:]
        self.flatarf = self.arflo * 0 + 10.1
        amid = (self.arflo + self.arfhi) / 2.0
        self.arf = 10 - (3.0 - amid)**2

    def tearDown(self):
        # there's an issue in CIAO 4.8 with delete_model and
        # delete_model_component, so just call clean
        """
        for idval in [1, "tst"]:
            ui.delete_model(id=idval)
            ui.delete_model_component("pl{}".format(idval))
            ui.delete_data(id=idval)

        ui.delete_data(id="not-used")
        """
        ui.clean()

    def test_invalid_id(self):

        self.assertRaises(IdentifierErr, utils.get_instmap_weights,