# Path: calliope/exceptions.py
# def _formatwarning(message, category, filename, lineno, line=None):
# def warn(message, _class=ModelWarning):
# def print_warnings_and_raise_errors(warnings=None, errors=None):
# class ModelError(Exception):
# class BackendError(Exception):
# class ModelWarning(Warning):
# class BackendWarning(Warning):
# 
# Path: calliope/time/funcs.py
# def get_daily_timesteps(data, check_uniformity=False):
# def normalized_copy(data):
# def _copy_non_t_vars(data0, data1):
# def _combine_datasets(data0, data1):
# def _drop_timestep_vars(data, timesteps):
# def apply_clustering(
#     data,
#     timesteps,
#     clustering_func,
#     how,
#     normalize=True,
#     scale_clusters="mean",
#     storage_inter_cluster=True,
#     model_run=None,
#     **kwargs,
# ):
# def resample(data, timesteps, resolution):
#     def _resample(var, how):
# def drop(data, timesteps):
# def lookup_clusters(dataset):
# 
# Path: calliope/time/masks.py
# def _get_array(data, var, tech, **kwargs):
# def zero(data, tech, var="resource", **kwargs):
# def _concat_indices(indices):
# def _get_minmax_timestamps(series, length, n, how="max", padding=None):
# def extreme(
#     data,
#     tech,
#     var="resource",
#     how="max",
#     length="1D",
#     n=1,
#     groupby_length=None,
#     padding=None,
#     normalize=True,
#     **kwargs,
# ):
# def extreme_diff(
#     data,
#     tech0,
#     tech1,
#     var="resource",
#     how="max",
#     length="1D",
#     n=1,
#     groupby_length=None,
#     padding=None,
#     normalize=True,
#     **kwargs,
# ):
# def _extreme(arr, how="max", length="1D", n=1, groupby_length=None, padding=None):
# def _extreme_with_padding(arr, how, length, n, groupby_length, padding):
# def _calendar_week_padding(day, arr):
# 
# Path: calliope/test/common/util.py
# def build_test_model(
#     override_dict=None,
#     scenario=None,
#     model_file="model.yaml",
#     timeseries_dataframes=None,
# ):
# def check_error_or_warning(error_warning, test_string_or_strings):
# def check_variable_exists(backend_model, constraint, variable, idx=None):


import pandas as pd
import numpy as np
import pytest  # noqa: F401
import calliope
from calliope import exceptions
from calliope.time import funcs, masks
from calliope.test.common.util import (
    build_test_model,
    check_error_or_warning,
    python36_or_higher,
)
            **{
                "model.subset_time": ["2005-01-01", "2005-01-06"],
                "model.time.function_options.clustering_func": "file=cluster_days.csv:b",
            },
        }

        with pytest.raises(exceptions.ModelError) as error:
            build_test_model(override4, scenario="simple_supply")

        assert check_error_or_warning(
            error,
            "Missing data for the timeseries array(s) [('cluster_days.csv', 'a') ('cluster_days.csv', 'b')]",
        )


class TestMasks:
    @pytest.fixture
    def model_national(self, scope="module"):
        return calliope.examples.national_scale(
            override_dict={"model.subset_time": ["2005-01-01", "2005-01-31"]}
        )

    @pytest.fixture
    def model_urban(self, scope="module"):
        return calliope.examples.urban_scale(
            override_dict={"model.subset_time": ["2005-01-01", "2005-01-31"]}
        )

    def test_zero(self, model_national):
        data = model_national._model_data_pre_clustering.copy()

# Path: calliope/exceptions.py
# def _formatwarning(message, category, filename, lineno, line=None):
# def warn(message, _class=ModelWarning):
# def print_warnings_and_raise_errors(warnings=None, errors=None):
# class ModelError(Exception):
# class BackendError(Exception):
# class ModelWarning(Warning):
# class BackendWarning(Warning):
# 
# Path: calliope/time/funcs.py
# def get_daily_timesteps(data, check_uniformity=False):
# def normalized_copy(data):
# def _copy_non_t_vars(data0, data1):
# def _combine_datasets(data0, data1):
# def _drop_timestep_vars(data, timesteps):
# def apply_clustering(
#     data,
#     timesteps,
#     clustering_func,
#     how,
#     normalize=True,
#     scale_clusters="mean",
#     storage_inter_cluster=True,
#     model_run=None,
#     **kwargs,
# ):
# def resample(data, timesteps, resolution):
#     def _resample(var, how):
# def drop(data, timesteps):
# def lookup_clusters(dataset):
# 
# Path: calliope/time/masks.py
# def _get_array(data, var, tech, **kwargs):
# def zero(data, tech, var="resource", **kwargs):
# def _concat_indices(indices):
# def _get_minmax_timestamps(series, length, n, how="max", padding=None):
# def extreme(
#     data,
#     tech,
#     var="resource",
#     how="max",
#     length="1D",
#     n=1,
#     groupby_length=None,
#     padding=None,
#     normalize=True,
#     **kwargs,
# ):
# def extreme_diff(
#     data,
#     tech0,
#     tech1,
#     var="resource",
#     how="max",
#     length="1D",
#     n=1,
#     groupby_length=None,
#     padding=None,
#     normalize=True,
#     **kwargs,
# ):
# def _extreme(arr, how="max", length="1D", n=1, groupby_length=None, padding=None):
# def _extreme_with_padding(arr, how, length, n, groupby_length, padding):
# def _calendar_week_padding(day, arr):
# 
# Path: calliope/test/common/util.py
# def build_test_model(
#     override_dict=None,
#     scenario=None,
#     model_file="model.yaml",
#     timeseries_dataframes=None,
# ):
# def check_error_or_warning(error_warning, test_string_or_strings):
# def check_variable_exists(backend_model, constraint, variable, idx=None):


# Path: calliope/test/test_core_time.py
import pandas as pd
import numpy as np
import pytest  # noqa: F401
import calliope
from calliope import exceptions
from calliope.time import funcs, masks
from calliope.test.common.util import (
    build_test_model,
    check_error_or_warning,
    python36_or_higher,
)

            **{
                "model.subset_time": ["2005-01-01", "2005-01-06"],
                "model.time.function_options.clustering_func": "file=cluster_days.csv:b",
            },
        }

        with pytest.raises(exceptions.ModelError) as error:
            build_test_model(override4, scenario="simple_supply")

        assert check_error_or_warning(
            error,
            "Missing data for the timeseries array(s) [('cluster_days.csv', 'a') ('cluster_days.csv', 'b')]",
        )


class TestMasks:
    @pytest.fixture
    def model_national(self, scope="module"):
        return calliope.examples.national_scale(
            override_dict={"model.subset_time": ["2005-01-01", "2005-01-31"]}
        )

    @pytest.fixture
    def model_urban(self, scope="module"):
        return calliope.examples.urban_scale(
            override_dict={"model.subset_time": ["2005-01-01", "2005-01-31"]}
        )

    def test_zero(self, model_national):
        data = model_national._model_data_pre_clustering.copy()

        mask = masks.zero(data, "csp", var="resource")