# Path: cis/utils.py
# def index_iterator_for_non_masked_data(shape, points):
#     """Iterates over the indexes of a multi-dimensional array of a specified shape.
#     The last index changes most rapidly.
# 
#     :param shape: sequence of array dimensions
#     :return: yields tuples of array indexes
#     """
# 
#     # dim = len(shape)
#     # idx = [0] * dim
#     # num_iterations = 1
#     # for j in range(0, dim):
#     #     num_iterations *= shape[j]
#     num_cells = np.product(shape)
#     cell_count = 0
#     cell_total = 0
# 
#     it = np.nditer(points.data, flags=['multi_index'])
#     while not it.finished:
#         if it[0] is not np.ma.masked:
#             yield it.multi_index
# 
#         it.iternext()
# 
#         # Log progress periodically.
#         if cell_count == 10000:
#             cell_total += 1
#             number_cells_processed = cell_total * 10000
#             logging.info("    Processed %d points of %d (%d%%)", number_cells_processed, num_cells,
#                          int(number_cells_processed * 100 / num_cells))
#             cell_count = 0
#         cell_count += 1
# 
# def index_iterator_nditer(shape, points):
#     """Iterates over the indexes of a multi-dimensional array of a specified shape.
#     The last index changes most rapidly.
# 
#     :param shape: sequence of array dimensions
#     :return: yields tuples of array indexes
#     """
# 
#     num_cells = np.product(shape)
#     cell_count = 0
#     cell_total = 0
# 
#     it = np.nditer(points, flags=['multi_index'])
#     while not it.finished:
#         yield it.multi_index
# 
#         # Log progress periodically.
#         if cell_count == 10000:
#             cell_total += 1
#             number_cells_processed = cell_total * 10000
#             logging.info("    Processed %d points of %d (%d%%)", number_cells_processed, num_cells,
#                          int(number_cells_processed * 100 / num_cells))
#             cell_count = 0
#         cell_count += 1
# 
#         it.iternext()


from abc import ABCMeta, abstractmethod
from cis.utils import index_iterator_for_non_masked_data, index_iterator_nditer
        from cis.collocation.col_implementations import HyperPoint
        from cis.collocation.col_implementations import HyperPoint
        from cis.collocation.col_implementations import HyperPoint
    from cis.plugin import find_plugin_classes
    from cis.exceptions import ClassNotFoundError
    from cis.exceptions import ClassNotFoundError
import six
import numpy as np
    import logging
    __metaclass__ = ABCMeta

    def get_iterator(self, missing_data_for_missing_sample, coord_map, coords, data_points, shape, points, output_data):
        if missing_data_for_missing_sample:
            iterator = index_iterator_for_non_masked_data(shape, points)
        else:
            iterator = index_iterator_nditer(shape, output_data[0])

        for indices in iterator:
            hp_values = [None] * HyperPoint.number_standard_names
            hp_cell_values = [None] * HyperPoint.number_standard_names
            for (hpi, ci, shi) in coord_map:
                hp_values[hpi] = coords[ci].points[indices[shi]]
                hp_cell_values[hpi] = coords[ci].cell(indices[shi])

            hp = HyperPoint(*hp_values)
            constrained_points = self.constrain_points(HyperPoint(*hp_cell_values), data_points)
            yield indices, hp, constrained_points


# noinspection PyAbstractClass
class IndexedConstraint(Constraint):
    """Superclass of constraints that expect points to be referenced by index.
    """
    __metaclass__ = ABCMeta

    def get_iterator(self, missing_data_for_missing_sample, coord_map, coords, data_points, shape, points, output_data):
        if missing_data_for_missing_sample:
            iterator = index_iterator_for_non_masked_data(shape, points)
        else:

# Path: cis/utils.py
# def index_iterator_for_non_masked_data(shape, points):
#     """Iterates over the indexes of a multi-dimensional array of a specified shape.
#     The last index changes most rapidly.
# 
#     :param shape: sequence of array dimensions
#     :return: yields tuples of array indexes
#     """
# 
#     # dim = len(shape)
#     # idx = [0] * dim
#     # num_iterations = 1
#     # for j in range(0, dim):
#     #     num_iterations *= shape[j]
#     num_cells = np.product(shape)
#     cell_count = 0
#     cell_total = 0
# 
#     it = np.nditer(points.data, flags=['multi_index'])
#     while not it.finished:
#         if it[0] is not np.ma.masked:
#             yield it.multi_index
# 
#         it.iternext()
# 
#         # Log progress periodically.
#         if cell_count == 10000:
#             cell_total += 1
#             number_cells_processed = cell_total * 10000
#             logging.info("    Processed %d points of %d (%d%%)", number_cells_processed, num_cells,
#                          int(number_cells_processed * 100 / num_cells))
#             cell_count = 0
#         cell_count += 1
# 
# def index_iterator_nditer(shape, points):
#     """Iterates over the indexes of a multi-dimensional array of a specified shape.
#     The last index changes most rapidly.
# 
#     :param shape: sequence of array dimensions
#     :return: yields tuples of array indexes
#     """
# 
#     num_cells = np.product(shape)
#     cell_count = 0
#     cell_total = 0
# 
#     it = np.nditer(points, flags=['multi_index'])
#     while not it.finished:
#         yield it.multi_index
# 
#         # Log progress periodically.
#         if cell_count == 10000:
#             cell_total += 1
#             number_cells_processed = cell_total * 10000
#             logging.info("    Processed %d points of %d (%d%%)", number_cells_processed, num_cells,
#                          int(number_cells_processed * 100 / num_cells))
#             cell_count = 0
#         cell_count += 1
# 
#         it.iternext()


# Path: cis/collocation/col_framework.py
from abc import ABCMeta, abstractmethod
from cis.utils import index_iterator_for_non_masked_data, index_iterator_nditer
        from cis.collocation.col_implementations import HyperPoint
        from cis.collocation.col_implementations import HyperPoint
        from cis.collocation.col_implementations import HyperPoint
    from cis.plugin import find_plugin_classes
    from cis.exceptions import ClassNotFoundError
    from cis.exceptions import ClassNotFoundError
import six
import numpy as np
    import logging

    __metaclass__ = ABCMeta

    def get_iterator(self, missing_data_for_missing_sample, coord_map, coords, data_points, shape, points, output_data):
        if missing_data_for_missing_sample:
            iterator = index_iterator_for_non_masked_data(shape, points)
        else:
            iterator = index_iterator_nditer(shape, output_data[0])

        for indices in iterator:
            hp_values = [None] * HyperPoint.number_standard_names
            hp_cell_values = [None] * HyperPoint.number_standard_names
            for (hpi, ci, shi) in coord_map:
                hp_values[hpi] = coords[ci].points[indices[shi]]
                hp_cell_values[hpi] = coords[ci].cell(indices[shi])

            hp = HyperPoint(*hp_values)
            constrained_points = self.constrain_points(HyperPoint(*hp_cell_values), data_points)
            yield indices, hp, constrained_points


# noinspection PyAbstractClass
class IndexedConstraint(Constraint):
    """Superclass of constraints that expect points to be referenced by index.
    """
    __metaclass__ = ABCMeta

    def get_iterator(self, missing_data_for_missing_sample, coord_map, coords, data_points, shape, points, output_data):
        if missing_data_for_missing_sample:
            iterator = index_iterator_for_non_masked_data(shape, points)
        else:

            iterator = index_iterator_nditer(shape, output_data[0])