# Path: ciao_contrib/logger_wrapper.py
# def get_verbosity():
#     """Returns the verbosity of the contrib logging
#     level cxc.ciao.contrib. This is the level in the hierarchy
#     which "general users" should use for logging.
# 
#     It does not check the hierarchy for whether 'parent'
#     or 'child' elements have a different verbosity.
#     """
# 
#     return logging.getLogger(lhead).verbose
# 
# def set_verbosity(verbose=1):
#     """Sets the verbosity of the contrib logging
#     level cxc.ciao.contrib. This is the level in the hierarchy
#     which "general users" should use for logging.
# 
#     It does not check the hierarchy for whether 'parent'
#     or 'child' elements have a different verbosity and
#     so should also be changed.
# 
#     A value of -1 means "unset".
#     """
# 
#     _check_verbose(verbose)
#     logging.getLogger(lhead).verbose = verbose
# 
# Path: ciao_contrib/_tools/utils.py
# def list_multi_obi_obsids():
# def is_multi_obi_obsid(obsid):
#     def __init__(self, obsid, cycle=None, obi=None):
#     def obsid(self):
#     def cycle(self):
#     def obi(self):
#     def is_multi_obi(self):
#     def is_multi_obi(self, flag):
#     def __str__(self):
#     def __repr__(self):
#     def __eq__(self, rhs):
#     def __ne__(self, rhs):
#     def __lt__(self, rhs):
#     def __hash__(self):
# def make_obsid_from_headers(headers, infile=None):
# def print_version(toolname, version):
# def split_outroot(outroot):
# def to_number(inval):
# def equal_elements(ls):
# def getUniqueSynset(ls):
# def thresh_is_set(val):
# def parse_range(rstr):
# def parse_xygrid(gstr):
# def parse_refpos(refpos):
# def sky_to_arcsec(instrume, pixsize):
# def process_tmpdir(tmpdir):
# class MultiObiError(ValueError):
# class ObsId:


import pytest
from ciao_contrib.logger_wrapper import get_verbosity, set_verbosity
from ciao_contrib._tools import utils

    with pytest.raises(ValueError) as ve:
        utils.parse_xygrid(invalid)

    assert str(ve.value) == msg


def test_parse_xygrid_string_square():

    outstr, binsize, xrng, yrng, nbins = utils.parse_xygrid('2:12:1, 3:12:1')
    assert outstr == 'x=2:12:1,y= 3:12:1'
    assert binsize == 1
    assert xrng == (2, 12)
    assert yrng == (3, 12)
    assert nbins == (10, 9)


def test_parse_xygrid_string_rectangle():

    outstr, binsize, xrng, yrng, nbins = utils.parse_xygrid('2:12:#10,3:12:#18')
    assert outstr == 'x=2:12:#10,y=3:12:#18'
    assert binsize == 0.5
    assert xrng == (2, 12)
    assert yrng == (3, 12)
    assert nbins == (10, 18)


@pytest.mark.parametrize("invalid", ["12", "foobar", "12 , 13,14", ",23", " ,  23  "])
def test_parse_refpos_string_errors(invalid):
    with pytest.raises(ValueError) as ve:

# Path: ciao_contrib/logger_wrapper.py
# def get_verbosity():
#     """Returns the verbosity of the contrib logging
#     level cxc.ciao.contrib. This is the level in the hierarchy
#     which "general users" should use for logging.
# 
#     It does not check the hierarchy for whether 'parent'
#     or 'child' elements have a different verbosity.
#     """
# 
#     return logging.getLogger(lhead).verbose
# 
# def set_verbosity(verbose=1):
#     """Sets the verbosity of the contrib logging
#     level cxc.ciao.contrib. This is the level in the hierarchy
#     which "general users" should use for logging.
# 
#     It does not check the hierarchy for whether 'parent'
#     or 'child' elements have a different verbosity and
#     so should also be changed.
# 
#     A value of -1 means "unset".
#     """
# 
#     _check_verbose(verbose)
#     logging.getLogger(lhead).verbose = verbose
# 
# Path: ciao_contrib/_tools/utils.py
# def list_multi_obi_obsids():
# def is_multi_obi_obsid(obsid):
#     def __init__(self, obsid, cycle=None, obi=None):
#     def obsid(self):
#     def cycle(self):
#     def obi(self):
#     def is_multi_obi(self):
#     def is_multi_obi(self, flag):
#     def __str__(self):
#     def __repr__(self):
#     def __eq__(self, rhs):
#     def __ne__(self, rhs):
#     def __lt__(self, rhs):
#     def __hash__(self):
# def make_obsid_from_headers(headers, infile=None):
# def print_version(toolname, version):
# def split_outroot(outroot):
# def to_number(inval):
# def equal_elements(ls):
# def getUniqueSynset(ls):
# def thresh_is_set(val):
# def parse_range(rstr):
# def parse_xygrid(gstr):
# def parse_refpos(refpos):
# def sky_to_arcsec(instrume, pixsize):
# def process_tmpdir(tmpdir):
# class MultiObiError(ValueError):
# class ObsId:


# Path: ciao_contrib/_tools/tests/test_ciao_contrib_tools_utils.py
import pytest
from ciao_contrib.logger_wrapper import get_verbosity, set_verbosity
from ciao_contrib._tools import utils


    with pytest.raises(ValueError) as ve:
        utils.parse_xygrid(invalid)

    assert str(ve.value) == msg


def test_parse_xygrid_string_square():

    outstr, binsize, xrng, yrng, nbins = utils.parse_xygrid('2:12:1, 3:12:1')
    assert outstr == 'x=2:12:1,y= 3:12:1'
    assert binsize == 1
    assert xrng == (2, 12)
    assert yrng == (3, 12)
    assert nbins == (10, 9)


def test_parse_xygrid_string_rectangle():

    outstr, binsize, xrng, yrng, nbins = utils.parse_xygrid('2:12:#10,3:12:#18')
    assert outstr == 'x=2:12:#10,y=3:12:#18'
    assert binsize == 0.5
    assert xrng == (2, 12)
    assert yrng == (3, 12)
    assert nbins == (10, 18)


@pytest.mark.parametrize("invalid", ["12", "foobar", "12 , 13,14", ",23", " ,  23  "])
def test_parse_refpos_string_errors(invalid):
    with pytest.raises(ValueError) as ve:

        utils.parse_refpos(invalid)