コード例 #1
0
ファイル: state_enum.py プロジェクト: SysSynBio/PyME
    def indices(self, states):
        """
        indices(states) -> index_array
        
        returns an array of the enumeration indices for the
        states stored in the array 'states'.
        """
        if self.stoc_vec == None:
            states = numpy.asarray(states)
        else:
            states = numpy.asarray(states[self.stoc_vec,:])

            # 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
        #pdb.set_trace()
        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)
        member_index = numpy.arange(len(self.index))[members]
        return member_index[unique_inverse]
コード例 #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'.
        """
        if self.stoc_vec is None:
            states = numpy.asarray(states)
        else:
            states = numpy.asarray(states[self.stoc_vec, :])

            # 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
        #pdb.set_trace()
        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)
        member_index = numpy.arange(len(self.index))[members]
        return member_index[unique_inverse]
コード例 #3
0
ファイル: state_enum.py プロジェクト: SysSynBio/PyME
 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.
     """
     if self.stoc_vec == None:
         states = numpy.asarray(states)
     else:
         states = numpy.asarray(states[self.stoc_vec,:])
     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]
コード例 #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.
     """
     if self.stoc_vec is None:
         states = numpy.asarray(states)
     else:
         states = numpy.asarray(states[self.stoc_vec, :])
     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]