<commit_before>#!/usr/bin/env python

"""
@package coverage_model.parameter
@file coverage_model/parameter.py
@author <NAME>
@brief Concrete parameter classes
"""

from ooi.logging import log
from coverage_model.basic_types import AbstractIdentifiable, VariabilityEnum, AxisTypeEnum
from coverage_model.parameter_types import AbstractParameterType, QuantityType
from coverage_model.parameter_functions import ParameterFunctionException
from collections import OrderedDict
import copy

#==================
# Parameter Objects
#==================

class Parameter(AbstractIdentifiable):
    """
    Container class to hold a ParameterContext and it's associated value
    """
    def __init__(self, parameter_context, shape, value):
        """
        Construct a new Parameter

        @param parameter_context The ParameterContext of the parameter
        @param shape    The shape of the parameter
        @param value    The AbstractParameterValue of the parameter
        """
        AbstractIdentifiable.__init__(self)
        self.context = parameter_context
        self.value = value
        self.shape = shape

    # Expose a couple of the context attributes at this level as "read only"
    @property
    def name(self):
        """
        Retrieve the name of the Parameter (via it's ParameterContext)

        @returns    The string name for the Parameter
        """
        return self.context.name

    @property
    def is_coordinate(self):
        """
        Indicates if the Parameter is a coordinate (via it's ParameterContext)

        @returns    True if it is a coordinate; False otherwise
        """
        return self.context.is_coordinate

class ParameterContext(AbstractIdentifiable):
    """
    Context for a parameter

    The ParameterContext is intended to fully describe a parameter in terms of:
    - typing: the param_type attribute should be one of the concrete implementations of AbstractParameterType (i.e. QuantityType)
        - The type may impart certain attributes to the ParameterContext.  For example, a ParameterContext of type QuantityType
     will have a uom (units of measure) attribute.
    - structure: from the perspective of the container (coverage-model, granule), this includes things such as axis
    (a.k.a. 'axis') and variability (one of the VariabilityEnum members).
    - data-critical-metadata: 'metadata' that is critical to the storage/processing of the data - such as fill_value, nil_value, etc.

    @todo: This will likely undergo moderate to significant changes as things continue to mature
    """

    # Dynamically added attributes - from ObjectType CI Attributes (2480139)
    ATTRS = ['attributes',
             'index_key',
             'ion_name',
#             'name', # accounted for as 'name'
#             'units', # accounted for as 'uom'
             'standard_name',
             'long_name',
             'ooi_short_name',
             'display_name',
#             'missing_value', # accounted for as 'fill_value'
             'cdm_data_type',
             'variable_reports',
#             'axis', # accounted for as 'axis'
             'references',
#             'comment', # accounted for as description
             'code_reports',]

    def __init__(self, name, param_type=None, axis=None, fill_value=None, variability=None, uom=None, **kwargs):
        """
        Construct a new ParameterContext object

        Must provide the 'name' argument.  It can be either a string indicating the name of the parameter, or an exising
        ParameterContext object that should be used as a template.
        If 'name' is a ParameterContext, a keyword argument 'new_name' can be provided which will be used as the name for
        the new ParameterContext.  If 'new_name' is not provided, the name will be the same as the template.

        When 'name' is a ParameterContext - the provided ParameterContext is utilized as a 'template' and it's attributes are copied into the new<commit_msg>Maps desired attribute names inside ParameterContext<commit_after>#!/usr/bin/env python

"""
@package coverage_model.parameter
@file coverage_model/parameter.py
@author <NAME>
@brief Concrete parameter classes
"""

from ooi.logging import log
from coverage_model.basic_types import AbstractIdentifiable, VariabilityEnum, AxisTypeEnum
from coverage_model.parameter_types import AbstractParameterType, QuantityType
from coverage_model.parameter_functions import ParameterFunctionException
from collections import OrderedDict
import copy

#==================
# Parameter Objects
#==================

class Parameter(AbstractIdentifiable):
    """
    Container class to hold a ParameterContext and it's associated value
    """
    def __init__(self, parameter_context, shape, value):
        """
        Construct a new Parameter

        @param parameter_context The ParameterContext of the parameter
        @param shape    The shape of the parameter
        @param value    The AbstractParameterValue of the parameter
        """
        AbstractIdentifiable.__init__(self)
        self.context = parameter_context
        self.value = value
        self.shape = shape

    # Expose a couple of the context attributes at this level as "read only"
    @property
    def name(self):
        """
        Retrieve the name of the Parameter (via it's ParameterContext)

        @returns    The string name for the Parameter
        """
        return self.context.name

    @property
    def is_coordinate(self):
        """
        Indicates if the Parameter is a coordinate (via it's ParameterContext)

        @returns    True if it is a coordinate; False otherwise
        """
        return self.context.is_coordinate

class ParameterContext(AbstractIdentifiable):
    """
    Context for a parameter

    The ParameterContext is intended to fully describe a parameter in terms of:
    - typing: the param_type attribute should be one of the concrete implementations of AbstractParameterType (i.e. QuantityType)
        - The type may impart certain attributes to the ParameterContext.  For example, a ParameterContext of type QuantityType
     will have a uom (units of measure) attribute.
    - structure: from the perspective of the container (coverage-model, granule), this includes things such as axis
    (a.k.a. 'axis') and variability (one of the VariabilityEnum members).
    - data-critical-metadata: 'metadata' that is critical to the storage/processing of the data - such as fill_value, nil_value, etc.

    @todo: This will likely undergo moderate to significant changes as things continue to mature
    """

    # Dynamically added attributes - from ObjectType CI Attributes (2480139)
    ATTRS = [
#             'attributes',
#             'index_key',
#             'ion_name',
#             'name', # accounted for as 'name'
#             'units', # accounted for as 'uom'
#             'standard_name',
#             'long_name',
#             'ooi_short_name',
#             'display_name',
#             'missing_value', # accounted for as 'fill_value'
#             'cdm_data_type',
#             'variable_reports',
#             'axis', # accounted for as 'axis'
#             'references',
#             'comment', # accounted for as description
#             'code_reports',]
            'reference_urls',
            'internal_name',
            'display_name', 
            'standard_name',
            'ooi_short_name',
            'description',
    ]

    def __init__(self, name, param_type=None, axis=None, fill_value=None, variability=None, uom=None, **kwargs):
        """
        Construct a new ParameterContext object

        Must provide the 'name' argument.  It can be either a string indicating the name of the parameter, or an exising
        ParameterContext object that should be used as a template.
        If 'name' is a ParameterContext, a keyword argument 'new_name' can be provided which will be used as the name for
        the new ParameterContext.  If 'new_name' is not provided, the name will be the same as the template.

        When 'name' is a ParameterContext - the provided ParameterContext is utilized as a 'template' and it's attributes are copied into the new
{'fraction_non_alphanumeric': 0.07804878048780488, 'fraction_numerical': 0.0017073170731707317, 'mean_word_length': 2.835827876520112, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1433290', 'n_tokens_mistral': 2059, 'n_tokens_neox': 1986, 'n_words': 816}