# Path: cmepy/domain.py
# def from_rect(shape, slices=None, origin=None):
# def from_iter(state_iter):
# def from_mapping(state_mapping):
# def to_iter(state_array):
# 
# Path: cmepy/lexarrayset.py
# def unique(las, return_inverse=False):
# def nonunique_member(arr1, las2):
# def member(las1, las2):
# def split(las1, las2):
# def difference(las1, las2):
# def intersection(las1, las2):
# def union(las1, las2):
# def shift(las, offset):
# def empty(dim):
# def create(data, unique_data=False):
#     def __init__(self, data, unique_data=False):
#     def size(self):
#     def member(self, rhs):
#     def split(self, rhs):
#     def difference(self, rhs):
#     def intersection(self, rhs):
#     def union(self, rhs):
#     def shift(self, offset):
#     def difference_update(self, rhs):
#     def intersection_update(self, rhs):
#     def union_update(self, rhs):
#     def shift_update(self, shift):
# class LexArraySet(object):
# 
# Path: cmepy/statistics.py
# @property
# def statistics(self):
#     return {
#         'expectation' : self.expectation,
#         'expected_value' : self.expectation,
#         'variance' : self.variance,
#         'covariance' : self.covariance,
#         'standard_deviation' : self.standard_deviation
#     }


import itertools
import numpy
from cmepy import domain, lexarrayset, statistics
        convenience routine to translate a distribution from a dictionary to
        a dense array, using this state enumeration 
        """
        
        if p_dense is None:
            p_dense = numpy.zeros((self.size, ), dtype=numpy.float)
        
        # guard against case where p_sparse is empty
        if len(p_sparse) == 0:
            return p_dense
        
        p_states, p_values = domain.from_mapping(p_sparse)
        
        # now sort the states, keeping them synchronised with the
        # ordering of the values
        order = numpy.lexsort(p_states)
        p_states = p_states[:, order]
        p_values = p_values[order]
        p_indices = self.indices(p_states)
        p_dense[p_indices] = p_values
        return p_dense
        
    
    def unpack_distribution(self, p_dense, p_sparse=None):
        """
        convenience routine to translate a distribution from a dense array
        to a dictionary, using this state enumeration
        """
        p_indices = numpy.arange(numpy.size(p_dense))
        # convert from list of coordinate vectors to list of states

# Path: cmepy/domain.py
# def from_rect(shape, slices=None, origin=None):
# def from_iter(state_iter):
# def from_mapping(state_mapping):
# def to_iter(state_array):
# 
# Path: cmepy/lexarrayset.py
# def unique(las, return_inverse=False):
# def nonunique_member(arr1, las2):
# def member(las1, las2):
# def split(las1, las2):
# def difference(las1, las2):
# def intersection(las1, las2):
# def union(las1, las2):
# def shift(las, offset):
# def empty(dim):
# def create(data, unique_data=False):
#     def __init__(self, data, unique_data=False):
#     def size(self):
#     def member(self, rhs):
#     def split(self, rhs):
#     def difference(self, rhs):
#     def intersection(self, rhs):
#     def union(self, rhs):
#     def shift(self, offset):
#     def difference_update(self, rhs):
#     def intersection_update(self, rhs):
#     def union_update(self, rhs):
#     def shift_update(self, shift):
# class LexArraySet(object):
# 
# Path: cmepy/statistics.py
# @property
# def statistics(self):
#     return {
#         'expectation' : self.expectation,
#         'expected_value' : self.expectation,
#         'variance' : self.variance,
#         'covariance' : self.covariance,
#         'standard_deviation' : self.standard_deviation
#     }


# Path: cmepy/state_enum.py
import itertools
import numpy
from cmepy import domain, lexarrayset, statistics

        convenience routine to translate a distribution from a dictionary to
        a dense array, using this state enumeration 
        """
        
        if p_dense is None:
            p_dense = numpy.zeros((self.size, ), dtype=numpy.float)
        
        # guard against case where p_sparse is empty
        if len(p_sparse) == 0:
            return p_dense
        
        p_states, p_values = domain.from_mapping(p_sparse)
        
        # now sort the states, keeping them synchronised with the
        # ordering of the values
        order = numpy.lexsort(p_states)
        p_states = p_states[:, order]
        p_values = p_values[order]
        p_indices = self.indices(p_states)
        p_dense[p_indices] = p_values
        return p_dense
        
    
    def unpack_distribution(self, p_dense, p_sparse=None):
        """
        convenience routine to translate a distribution from a dense array
        to a dictionary, using this state enumeration
        """
        p_indices = numpy.arange(numpy.size(p_dense))
        # convert from list of coordinate vectors to list of states

        p_states = domain.to_iter(self.states(p_indices))