Beispiel #1
0
    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]
Beispiel #2
0
 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]
Beispiel #3
0
    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]
Beispiel #4
0
 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]