# Path: calliope/backend/pyomo/util.py
# @memoize
# def get_param(backend_model, var, dims):
#     """
#     Get an input parameter held in a Pyomo object, or held in the defaults
#     dictionary if that Pyomo object doesn't exist.
# 
#     Parameters
#     ----------
#     backend_model : Pyomo model instance
#     var : str
#     dims : single value or tuple
# 
#     """
#     try:
#         return getattr(backend_model, var)[dims]
#     except AttributeError:  # i.e. parameter doesn't exist at all
#         logger.debug(
#             "get_param: var {} and dims {} leading to default lookup".format(var, dims)
#         )
#         return backend_model.__calliope_defaults[var]
#     except KeyError:  # try removing timestep
#         try:
#             if len(dims) > 2:
#                 return getattr(backend_model, var)[dims[:-1]]
#             else:
#                 return getattr(backend_model, var)[dims[0]]
#         except KeyError:  # Static default value
#             logger.debug(
#                 "get_param: var {} and dims {} leading to default lookup".format(
#                     var, dims
#                 )
#             )
#             return backend_model.__calliope_defaults[var]
# 
# def invalid(val) -> bool:
#     if isinstance(val, po.base.param._ParamData):
#         return val._value == po.Param.NoValue or po.value(val) is None
#     elif val == po.Param.NoValue:
#         return True
#     else:
#         return pd.isnull(val)


import pyomo.core as po
from calliope.backend.pyomo.util import get_param, invalid
"""
Copyright (C) since 2013 Calliope contributors listed in AUTHORS.
Licensed under the Apache 2.0 License (see LICENSE file).

capacity.py
~~~~~~~~~~~~~~~~~

Capacity constraints for technologies (output, resource, area, and storage).

"""




def get_capacity_bounds(bounds):
    def _get_bounds(backend_model, *idx):
        def _get_bound(bound):
            if bounds.get(bound) is not None:

# Path: calliope/backend/pyomo/util.py
# @memoize
# def get_param(backend_model, var, dims):
#     """
#     Get an input parameter held in a Pyomo object, or held in the defaults
#     dictionary if that Pyomo object doesn't exist.
# 
#     Parameters
#     ----------
#     backend_model : Pyomo model instance
#     var : str
#     dims : single value or tuple
# 
#     """
#     try:
#         return getattr(backend_model, var)[dims]
#     except AttributeError:  # i.e. parameter doesn't exist at all
#         logger.debug(
#             "get_param: var {} and dims {} leading to default lookup".format(var, dims)
#         )
#         return backend_model.__calliope_defaults[var]
#     except KeyError:  # try removing timestep
#         try:
#             if len(dims) > 2:
#                 return getattr(backend_model, var)[dims[:-1]]
#             else:
#                 return getattr(backend_model, var)[dims[0]]
#         except KeyError:  # Static default value
#             logger.debug(
#                 "get_param: var {} and dims {} leading to default lookup".format(
#                     var, dims
#                 )
#             )
#             return backend_model.__calliope_defaults[var]
# 
# def invalid(val) -> bool:
#     if isinstance(val, po.base.param._ParamData):
#         return val._value == po.Param.NoValue or po.value(val) is None
#     elif val == po.Param.NoValue:
#         return True
#     else:
#         return pd.isnull(val)


# Path: calliope/backend/pyomo/constraints/capacity.py
import pyomo.core as po
from calliope.backend.pyomo.util import get_param, invalid

"""
Copyright (C) since 2013 Calliope contributors listed in AUTHORS.
Licensed under the Apache 2.0 License (see LICENSE file).

capacity.py
~~~~~~~~~~~~~~~~~

Capacity constraints for technologies (output, resource, area, and storage).

"""




def get_capacity_bounds(bounds):
    def _get_bounds(backend_model, *idx):
        def _get_bound(bound):
            if bounds.get(bound) is not None:

                return get_param(backend_model, bounds.get(bound), idx)