<commit_before># -*- coding: utf-8 -*-
"""Encapsulates the outputs from a sector model

The output definitions are read in from ``outputs.yaml``.  For example::

        metrics:
        - name: total_cost
        - name: water_demand

"""
import logging
from collections import namedtuple

__author__ = "<NAME>, <NAME>"
__copyright__ = "<NAME>, <NAME>, University of Oxford 2017"
__license__ = "mit"


Output = namedtuple(
    "Output",
    [
        "name",
        "spatial_resolution",
        "temporal_resolution"
    ]
)


class OutputList(object):
    """Defines the types of outputs to a sector model

    Parameters
    ----------
    outputs: list
        A list of dict containing the name and spatial and temporal resolutions of the outputs
        For example::

                    [
                {
                    'name': 'water',
                    'spatial_resolution': 'LSOA',
                    'temporal_resolution': 'annual'
                },
                {
                    'name': 'cost',
                    'spatial_resolution': 'LSOA',
                    'temporal_resolution': 'annual'
                }
            ]

    """
    def __init__(self, outputs):
        self.logger = logging.getLogger(__name__)

        names = []
        spatial_resolutions = []
        temporal_resolutions = []
        for output in outputs:
            names.append(output['name'])
            spatial_resolutions.append(output['spatial_resolution'])
            temporal_resolutions.append(output['temporal_resolution'])
        self.names = names
        self.temporal_resolutions = temporal_resolutions
        self.spatial_resolutions = spatial_resolutions

    def __getitem__(self, key):

        output = Output(self.names[key],
                        self.spatial_resolutions[key],
                        self.temporal_resolutions[key])
        return output


class ModelOutputs(object):
    """A container for all the model outputs

    """
    def __init__(self, results):
        if 'metrics' not in results:
            results['metrics'] = []
        self._metrics = OutputList(results['metrics'])
        self.logger = logging.getLogger(__name__)
        self.logger.debug(results)

    @property
    def metrics(self):
        """A list of the model result metrics

        Returns
        =======
        :class:`smif.outputs.OutputList`<commit_msg>smif.outputs now uses smif.Parameter<commit_after># -*- coding: utf-8 -*-
"""Encapsulates the outputs from a sector model

The output definitions are read in from ``outputs.yaml``.  For example::

        metrics:
        - name: total_cost
        - name: water_demand

"""
import logging
from smif import Parameter

__author__ = "<NAME>, <NAME>"
__copyright__ = "<NAME>, <NAME>, University of Oxford 2017"
__license__ = "mit"


class OutputList(object):
    """Defines the types of outputs to a sector model

    Parameters
    ----------
    outputs: list
        A list of dict containing the name and spatial and temporal resolutions of the outputs
        For example::

                    [
                {
                    'name': 'water',
                    'spatial_resolution': 'LSOA',
                    'temporal_resolution': 'annual'
                },
                {
                    'name': 'cost',
                    'spatial_resolution': 'LSOA',
                    'temporal_resolution': 'annual'
                }
            ]

    """
    def __init__(self, outputs):
        self.logger = logging.getLogger(__name__)

        names = []
        spatial_resolutions = []
        temporal_resolutions = []
        for output in outputs:
            names.append(output['name'])
            spatial_resolutions.append(output['spatial_resolution'])
            temporal_resolutions.append(output['temporal_resolution'])
        self.names = names
        self.temporal_resolutions = temporal_resolutions
        self.spatial_resolutions = spatial_resolutions

    def __getitem__(self, key):

        output = Parameter(self.names[key],
                           self.spatial_resolutions[key],
                           self.temporal_resolutions[key])
        return output


class ModelOutputs(object):
    """A container for all the model outputs

    """
    def __init__(self, results):
        if 'metrics' not in results:
            results['metrics'] = []
        self._metrics = OutputList(results['metrics'])
        self.logger = logging.getLogger(__name__)
        self.logger.debug(results)

    @property
    def metrics(self):
        """A list of the model result metrics

        Returns
        =======
        :class:`smif.outputs.OutputList`
{'fraction_non_alphanumeric': 0.10517351500958058, 'fraction_numerical': 0.0021290185224611454, 'mean_word_length': 1.8928571428571428, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3987118', 'n_tokens_mistral': 1274, 'n_tokens_neox': 1165, 'n_words': 310}