예제 #1
0
파일: state_enum.py 프로젝트: kehlert/cmepy
    def indices(self, states):
        """
        indices(states) -> index_array
        
        returns an array of the enumeration indices for the
        states stored in the array 'states'.
        """

        states = numpy.asarray(states)

        # assume states is a two dimensional array with
        # potentially non unique rows

        # due to non-uniqueness, there is a bit of messing
        # about in order to reduce the states to
        # a unique set, find the indices for those states, then
        # invert the unique operation

        unique_states, unique_inverse = lexarrayset.unique(states,
                                                           return_inverse=True)

        # subtlety : we need the boolean array members to correspond
        # to the ordered states and thus also to the current index,
        # hence we test to see which elements of ordered_states
        # are contained in the unique states
        #
        # note that this differs from the members query in the
        # contains method

        members = lexarrayset.member(self.ordered_states, unique_states)
        member_index = numpy.array(self.index[members] + self.offset)
        return member_index[unique_inverse]
예제 #2
0
파일: state_enum.py 프로젝트: fcostin/cmepy
 def indices(self, states):
     """
     indices(states) -> index_array
     
     returns an array of the enumeration indices for the
     states stored in the array 'states'.
     """
     
     states = numpy.asarray(states)
     
     # assume states is a two dimensional array with
     # potentially non unique rows
     
     # due to non-uniqueness, there is a bit of messing
     # about in order to reduce the states to
     # a unique set, find the indices for those states, then
     # invert the unique operation
     
     unique_states, unique_inverse = lexarrayset.unique(states,
                                                        return_inverse=True)
     
     # subtlety : we need the boolean array members to correspond
     # to the ordered states and thus also to the current index,
     # hence we test to see which elements of ordered_states
     # are contained in the unique states
     #
     # note that this differs from the members query in the
     # contains method
     
     members = lexarrayset.member(self.ordered_states, unique_states)
     member_index = numpy.array(self.index[members] + self.offset)
     return member_index[unique_inverse]
예제 #3
0
파일: state_enum.py 프로젝트: kehlert/cmepy
    def reinitialise(self, initial_states):
        """
        reinitialise the StateEnumeration with the given 'initial_states'
        """

        initial_states = numpy.asarray(initial_states)

        self.unordered_states = lexarrayset.unique(initial_states)
        self.index = numpy.arange(self.unordered_states.shape[1])
        self.update_ordering()
        self.offset = 0
예제 #4
0
파일: state_enum.py 프로젝트: fcostin/cmepy
 def reinitialise(self, initial_states):
     """
     reinitialise the StateEnumeration with the given 'initial_states'
     """
     
     initial_states = numpy.asarray(initial_states)
     
     self.unordered_states = lexarrayset.unique(initial_states)
     self.index = numpy.arange(self.unordered_states.shape[1])
     self.update_ordering()
     self.offset = 0
예제 #5
0
파일: state_enum.py 프로젝트: kehlert/cmepy
    def extend(self, sigma):
        """
        Adds the states in the array 'sigma' to the state enumeration.
        
        These states must be disjoint to the existing states in this
        enumeration.
        
        The indexing of existing states in this enumeration will be
        unchanged.
        """

        sigma_unique = lexarrayset.unique(numpy.asarray(sigma))

        self.unordered_states = numpy.hstack(
            (self.unordered_states, sigma_unique))
        index = numpy.arange(self.size, self.size + sigma_unique.shape[1])
        self.index = numpy.concatenate((self.index, index))
        self.update_ordering()
예제 #6
0
파일: state_enum.py 프로젝트: fcostin/cmepy
 def extend(self, sigma):
     """
     Adds the states in the array 'sigma' to the state enumeration.
     
     These states must be disjoint to the existing states in this
     enumeration.
     
     The indexing of existing states in this enumeration will be
     unchanged.
     """
     
     sigma_unique = lexarrayset.unique(numpy.asarray(sigma))
     
     self.unordered_states = numpy.hstack((self.unordered_states,
                                           sigma_unique))
     index = numpy.arange(self.size, self.size+sigma_unique.shape[1])
     self.index = numpy.concatenate((self.index, index))
     self.update_ordering()
예제 #7
0
파일: state_enum.py 프로젝트: kehlert/cmepy
    def contains(self, states):
        """
        contains(states) -> bool_array
        
        returns a boolean array of flags indicates which of the
        states stored in the array 'states' are contained in the
        state enumeration.
        """

        states = numpy.asarray(states)

        unique_states, unique_inverse = lexarrayset.unique(states,
                                                           return_inverse=True)

        # subtlety : we need the boolean array members to correspond to the
        # unique states, hence we test to see which elements of the unique
        # states are contained in the ordered states
        #
        # note that this differs from the members query in the indices
        # method

        members = lexarrayset.member(unique_states, self.ordered_states)
        return members[unique_inverse]
예제 #8
0
파일: state_enum.py 프로젝트: fcostin/cmepy
 def contains(self, states):
     """
     contains(states) -> bool_array
     
     returns a boolean array of flags indicates which of the
     states stored in the array 'states' are contained in the
     state enumeration.
     """
     
     states = numpy.asarray(states)
     
     unique_states, unique_inverse = lexarrayset.unique(states,
                                                        return_inverse=True)
     
     # subtlety : we need the boolean array members to correspond to the
     # unique states, hence we test to see which elements of the unique
     # states are contained in the ordered states
     #
     # note that this differs from the members query in the indices
     # method
     
     members = lexarrayset.member(unique_states, self.ordered_states)
     return members[unique_inverse]