# Path: gammacat/info.py
# class GammaCatInfo:
# class GammaCatStr:
#     def __init__(self):
#     def __str__(self):
#     def info_dict(self):
#     def reference_folder(meta):
#     def data_filename(meta):
#     def source_id_str(source_id):
#     def reference_id_str(reference_id):
# def rawgit_url(filename, location='master', mode='production'):
# 
# Path: gammacat/modeling.py
# class Parameters:
#     """Container with parameter list data member.
#     """
# 
#     def __init__(self, parlist):
#         self.parlist = parlist
# 
#     def __repr__(self):
#         ss = 'ParameterSet with {} parameters:\n'.format(len(self.parlist))
#         for par in self.parlist:
#             ss += '- {!r}\n'.format(par)
#         return ss
# 
#     @classmethod
#     def from_dict(cls, data):
#         """Make parameter list from data as given in data files."""
#         parlist = []
#         for name, attrs in data.items():
#             pardict = dict(name=name)
#             pardict.update(attrs)
#             par = Parameter.from_dict(pardict)
#             parlist.append(par)
#         return cls(parlist=parlist)
# 
#     def __getitem__(self, item):
#         if isinstance(item, int):
#             return self.parlist[item]
#         elif isinstance(item, str):
#             names = [_.name for _ in self.parlist]
#             try:
#                 idx = names.index(item)
#             except ValueError:
#                 raise KeyError('No parameter name: {!r}. Parameters: {!r}'.format(item, names))
#             return self.parlist[idx]
#         else:
#             raise TypeError('Invalid item: {!r}. Must be a number of string.'.format(item))


from pathlib import Path
from ruamel.yaml import safe_load
from gammacat.info import gammacat_info
from gammacat.modeling import Parameters
import pytest
# Licensed under a 3-clause BSD style license - see LICENSE.rst


# pl spectrum example
# path = gammacat_info.base_dir / 'input/data/2011/2011A%26A...529A..49H/tev-000137.yaml'
# pl2 spectrum example
# filename = 'input/data/2016/2016arXiv161005799S/tev-000137.yaml'
# ecpl spectrum example
# TODO: @pytest.parametrize


def test_parameter_list():
    path = gammacat_info.in_path / 'data/2011/2011A%26A...529A..49H/tev-000137.yaml'
    data = safe_load(path.open())['spec']['model']['parameters']

# Path: gammacat/info.py
# class GammaCatInfo:
# class GammaCatStr:
#     def __init__(self):
#     def __str__(self):
#     def info_dict(self):
#     def reference_folder(meta):
#     def data_filename(meta):
#     def source_id_str(source_id):
#     def reference_id_str(reference_id):
# def rawgit_url(filename, location='master', mode='production'):
# 
# Path: gammacat/modeling.py
# class Parameters:
#     """Container with parameter list data member.
#     """
# 
#     def __init__(self, parlist):
#         self.parlist = parlist
# 
#     def __repr__(self):
#         ss = 'ParameterSet with {} parameters:\n'.format(len(self.parlist))
#         for par in self.parlist:
#             ss += '- {!r}\n'.format(par)
#         return ss
# 
#     @classmethod
#     def from_dict(cls, data):
#         """Make parameter list from data as given in data files."""
#         parlist = []
#         for name, attrs in data.items():
#             pardict = dict(name=name)
#             pardict.update(attrs)
#             par = Parameter.from_dict(pardict)
#             parlist.append(par)
#         return cls(parlist=parlist)
# 
#     def __getitem__(self, item):
#         if isinstance(item, int):
#             return self.parlist[item]
#         elif isinstance(item, str):
#             names = [_.name for _ in self.parlist]
#             try:
#                 idx = names.index(item)
#             except ValueError:
#                 raise KeyError('No parameter name: {!r}. Parameters: {!r}'.format(item, names))
#             return self.parlist[idx]
#         else:
#             raise TypeError('Invalid item: {!r}. Must be a number of string.'.format(item))


# Path: gammacat/tests/test_modeling.py
from pathlib import Path
from ruamel.yaml import safe_load
from gammacat.info import gammacat_info
from gammacat.modeling import Parameters
import pytest

# Licensed under a 3-clause BSD style license - see LICENSE.rst


# pl spectrum example
# path = gammacat_info.base_dir / 'input/data/2011/2011A%26A...529A..49H/tev-000137.yaml'
# pl2 spectrum example
# filename = 'input/data/2016/2016arXiv161005799S/tev-000137.yaml'
# ecpl spectrum example
# TODO: @pytest.parametrize


def test_parameter_list():
    path = gammacat_info.in_path / 'data/2011/2011A%26A...529A..49H/tev-000137.yaml'
    data = safe_load(path.open())['spec']['model']['parameters']

    pars = Parameters.from_dict(data)