<commit_before># -*- coding: utf-8 -*-
"""This module acts as a bridge to the sector models from the controller

The :class:`SectorModel` exposes several key methods for running wrapped
sector models.  To add a sector model to an instance of the framework,
first implement :class:`SectorModel`.

Key Functions
=============
This class performs several key functions which ease the integration of sector
models into the system-of-systems framework.

The user must implement the various abstract functions throughout the class to
provide an interface to the sector model, which can be called upon by the
framework. From the model's perspective, :class:`SectorModel` provides a bridge
from the sector-specific problem representation to the general representation
which allows reasoning across infrastructure systems.

The key functions include

* converting input/outputs to/from geographies/temporal resolutions
* converting control vectors from the decision layer of the framework, to
  asset Interventions specific to the sector model
* returning scaler/vector values to the framework to enable measurements of
  performance, particularly for the purposes of optimisation and rule-based
  approaches

"""
import logging
import os
from abc import ABC, abstractmethod

import importlib
from smif.metadata import ModelMetadata

__author__ = "<NAME>, <NAME>"
__copyright__ = "<NAME>, <NAME>"
__license__ = "mit"


class SectorModel(ABC):
    """A representation of the sector model with inputs and outputs

    """
    def __init__(self):
        self._model_name = None

        self.interventions = []
        self.system = []

        self._inputs = ModelMetadata({})
        self._outputs = ModelMetadata({})

        self.logger = logging.getLogger(__name__)

    def validate(self):
        """Validate that this SectorModel has been set up with sufficient data
        to run
        """
        pass

    @property
    def name(self):
        """The name of the sector model

        Returns
        =======
        str
            The name of the sector model
        """
        return self._model_name

    @name.setter
    def name(self, value):
        self._model_name = value

    @property
    def inputs(self):
        """The inputs to the model

        The inputs should be specified in a list.  For example::

                - name: eletricity_price
                  spatial_resolution: GB
                  temporal_resolution: annual

        Arguments
        =========
        value : list
            A list of dicts of inputs to the model.
            These includes parameters, assets and exogenous data

        Returns
        =======
        :class:`smif.metadata.ModelMetadata`

        """
        return self._inputs

    @inputs.setter
    def inputs(self, value=None):
        if value is not None:
            assert isinstance(value, list)
        else:
            value = []<commit_msg>Add units to SectorModel.inputs docstring<commit_after># -*- coding: utf-8 -*-
"""This module acts as a bridge to the sector models from the controller

The :class:`SectorModel` exposes several key methods for running wrapped
sector models.  To add a sector model to an instance of the framework,
first implement :class:`SectorModel`.

Key Functions
=============
This class performs several key functions which ease the integration of sector
models into the system-of-systems framework.

The user must implement the various abstract functions throughout the class to
provide an interface to the sector model, which can be called upon by the
framework. From the model's perspective, :class:`SectorModel` provides a bridge
from the sector-specific problem representation to the general representation
which allows reasoning across infrastructure systems.

The key functions include

* converting input/outputs to/from geographies/temporal resolutions
* converting control vectors from the decision layer of the framework, to
  asset Interventions specific to the sector model
* returning scaler/vector values to the framework to enable measurements of
  performance, particularly for the purposes of optimisation and rule-based
  approaches

"""
import logging
import os
from abc import ABC, abstractmethod

import importlib
from smif.metadata import ModelMetadata

__author__ = "<NAME>, <NAME>"
__copyright__ = "Will Usher, <NAME>"
__license__ = "mit"


class SectorModel(ABC):
    """A representation of the sector model with inputs and outputs

    """
    def __init__(self):
        self._model_name = None

        self.interventions = []
        self.system = []

        self._inputs = ModelMetadata({})
        self._outputs = ModelMetadata({})

        self.logger = logging.getLogger(__name__)

    def validate(self):
        """Validate that this SectorModel has been set up with sufficient data
        to run
        """
        pass

    @property
    def name(self):
        """The name of the sector model

        Returns
        =======
        str
            The name of the sector model
        """
        return self._model_name

    @name.setter
    def name(self, value):
        self._model_name = value

    @property
    def inputs(self):
        """The inputs to the model

        The inputs should be specified in a list.  For example::

                - name: electricity_price
                  spatial_resolution: GB
                  temporal_resolution: annual
                  units: £/kWh

        Arguments
        =========
        value : list
            A list of dicts of inputs to the model.
            These includes parameters, assets and exogenous data

        Returns
        =======
        :class:`smif.metadata.ModelMetadata`

        """
        return self._inputs

    @inputs.setter
    def inputs(self, value=None):
        if value is not None:
            assert isinstance(value, list)
        else:
            value = []
{'fraction_non_alphanumeric': 0.07411167512690356, 'fraction_numerical': 0.00033840947546531303, 'mean_word_length': 2.6487654320987652, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '2841215', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1369, 'n_words': 619}