当前位置: 首页>>代码示例>>Python>>正文


Python Comparison.same_vals函数代码示例

本文整理汇总了Python中utilities.Comparison.same_vals函数的典型用法代码示例。如果您正苦于以下问题:Python same_vals函数的具体用法?Python same_vals怎么用?Python same_vals使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了same_vals函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getAxisEndAtomAtPosition

    def getAxisEndAtomAtPosition(self, position):
        """
        Returns the axis end atom of the 'currentStruct' of self's editCommand, 
        at the given position. 
        Example: 
        If there are 4 Dnasegments being resized at the same time, the two 
        resize handles will be at the average end positions. When you resize
        these segments using , for example , the right handle, it loops through 
        the individual segments to resize those. While doing these, it needs to
        know the resize end axis atom. How to get that information? In 
        self.updateAverageEndPoints() (which is called earlier), we create 
        two lists for each end. Example: all end1 points are in 
        self.endPoint_1_list (including their average end point which is 
        self.end1) . So in this routine, we determine which of the list to 
        use based on <position> (which is  either of the average end points 
        i.e. self.end1 or self.end2) and then check which of the endPoints
        of the editCommand's currentStruct lies in this list.
        
        @TODO: This method will be SLOW if there are large number of structures
        being edited at once (i.e. large self._structList) . Needs revision.
        Needs revision.
        We can't use a dictionary because dict.key cant be a Vector object 
        (example dict[key] != ([1.0, 2.0, 3.0])) see the disabled code that 
        tried to use has_key of dict. Need to come up with a better search 
        algorithm. 
        """

        new_position = None

        for end in (self.end1, self.end2):
            if same_vals(position, end):

                if same_vals(end, self.end1):
                    lst = self.endPoints_1
                else:
                    lst = self.endPoints_2

                for e in self.editCommand.currentStruct.getAxisEndPoints():
                    for pos in lst:
                        if same_vals(pos, e):
                            new_position = e
                            break
                        if new_position is not None:
                            break
                    ##if e in lst:
                    ##new_position = e
                    ##break

        ##if self.endPointsDict.has_key(position):
        ##for end in self.editCommand.currentStruct.getAxisEndPoints():
        ##if end in self.endPointsDict[position]:
        ##new_position = end
        ##break

        if new_position is not None:
            return self.editCommand.currentStruct.getAxisEndAtomAtPosition(
                new_position)

        return None
开发者ID:nmz787,项目名称:nanoengineer,代码行数:59,代码来源:DnaSegmentList.py

示例2: _update_UI_do_updates

 def _update_UI_do_updates(self):
     """
     Overrides superclass method. 
     
     @see: Command_PropertyManager._update_UI_do_updates()
     """
     
     newSelectionParams = self._currentSelectionParams()
     current_struct_params = self._currentStructureParams()
     
     selection_params_unchanged = same_vals(newSelectionParams,
                                            self._previousSelectionParams)
     
     #introducing self._previousStructureParams and 
     #adding structure_params_unchanged check to the 'if' condition below 
     #fixes bug 2910. 
     structure_params_unchanged = same_vals(self._previousStructureParams, 
                                             current_struct_params)
     
     current_command_stack_params = self._currentCommandStackParams()
     
     #Check if command stack params changed since last call of this 
     #PM update method. This is used to fix bugs like 2940
     command_stack_params_unchanged = same_vals(
         self._previousCommandStackParams, current_command_stack_params)
           
     #No need to proceed if any of the selection/ structure and commandstack 
     #parameters remained unchanged since last call. --- [CONDITION A]
     if selection_params_unchanged and \
        structure_params_unchanged and \
        command_stack_params_unchanged:
         return
     
     self._previousStructureParams = current_struct_params
     self._previousSelectionParams =  newSelectionParams         
     self._previousCommandStackParams  = current_command_stack_params
     
     if structure_params_unchanged: 
         #NOTE: We checked if either of the selection struct or command stack
         #parameters or both changed. (this was referred as '[CONDITION A]' 
         #above). So, this condition (structure_params_unchanged)also means 
         #either selection or command stack or both parameters were changed.    
         
         if not command_stack_params_unchanged:
             #update the nanotube list widget *before* updating the selection if 
             #the command stack changed. This ensures that the selection box
             #appears around the list widget items that are selected.
             self.updateNanotubesListWidget()
             
         selectedNanotubeSegments = newSelectionParams    
         
         self.nanotubeListWidget.updateSelection(selectedNanotubeSegments) 
         
         self.updateNanotubePropertiesButton()
         return
     
     self.updateNanotubesListWidget()
     return
开发者ID:elfion,项目名称:nanoengineer,代码行数:58,代码来源:BuildNanotube_PropertyManager.py

示例3: _update_UI_do_updates

 def _update_UI_do_updates(self):
     """
     Overrides superclass method.
     @see: PasteFromClipboard_Command.command_update_internal_state() which 
     is called before any command/ PM update UI.
     """    
     currentParams = self._current_model_changed_params()
     
     if same_vals(currentParams, self._previous_model_changed_params):
         return 
     
     #update the self._previous_model_changed_params with this new param set.
     self._previous_model_changed_params = currentParams 
     
     self.update_clipboard_items() 
     # Fixes bugs 1569, 1570, 1572 and 1573. mark 060306.
     # Note and bugfix, bruce 060412: doing this now was also causing 
     # traceback bugs 1726, 1629,
     # and the traceback part of bug 1677, and some related 
     #(perhaps unreported) bugs.
     # The problem was that this is called during pasteBond's addmol 
     #(due to its addchild), before it's finished,
     # at a time when the .part structure is invalid (since the added 
     # mol's .part has not yet been set).
     # To fix bugs 1726, 1629 and mitigate bug 1677, I revised the 
     # interface to MMKit.update_clipboard_items
     # (in the manner which was originally recommented in 
     #call_after_next_changed_members's docstring) 
     # so that it only sets a flag and updates (triggering an MMKit 
     # repaint event), deferring all UI effects to
     # the next MMKit event.
     pass 
开发者ID:elfion,项目名称:nanoengineer,代码行数:32,代码来源:PastePropertyManager.py

示例4: model_changed

    def model_changed(self):
        """       
        When the editCommand is treated as a 'command' by the 
        commandSequencer. this method will override basicCommand.model_changed.
        
        @WARNING: Ideally this property manager should implement both
               model_changed and selection_changed methods in the mode/command
               API. 
               model_changed method will be used here when the selected atom is 
               dragged, transmuted etc. The selection_changed method will be 
               used when the selection (picking/ unpicking) changes. 
               At present, selection_changed and model_changed methods are 
               called too frequently that it doesn't matter which one you use. 
               Its better to use only a single method for preformance reasons 
               (at the moment). This should change when the original 
               methods in the API are revised to be called at appropiraite 
               time. 
        """  
        newSelectionParams = self._currentSelectionParams()          
        if same_vals(newSelectionParams, self.previousSelectionParams):
            return
        
        self.previousSelectionParams = newSelectionParams  
        
        selectedSegments = newSelectionParams

        self.segmentListWidget.updateSelection(selectedSegments)
                
        if len(selectedSegments) == 1:
            self.editSegmentPropertiesButton.setEnabled(True)
        else:
            self.editSegmentPropertiesButton.setEnabled(False)
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:32,代码来源:BuildNanotube_PropertyManager.py

示例5: command_update_UI

 def command_update_UI(self):
     """
     Extends superclass method.
     """
     _superclass.command_update_UI(self)
     #Ths following code fixes a bug reported by Mark on 2008-11-10
     #the bug is:
         #1. Insert DNA
         #2. Enter Break Strands command. Exit command.
         #3. Do a region selection to select the middle of the DNA duplex.
         #Notice that atoms are selected, not the strands/segment chunks.
     #The problem is the selection state is not changed back to the Select Chunks
     #the code that does this is in Enter_GraphicsMode. 
     #(See SelectChunks_GraphicsMode) but when a command is 'resumed', that
     #method is not called. The fix for this is to check if the command stack
     #indicator changed in the command_update_state method, if it is changed
     #and if currentCommand is BuildDna_EditCommand, call the code that 
     #ensures that chunks will be selected when you draw a selection lasso.
     #-- Ninad 2008-11-10
     indicator = self.assy.command_stack_change_indicator()
     if same_vals(self.__previous_command_stack_change_indicator,
                  indicator):
         return 
     
     self.__previous_command_stack_change_indicator = indicator
     self.assy.selectChunksWithSelAtoms_noupdate()
     return
开发者ID:elfion,项目名称:nanoengineer,代码行数:27,代码来源:SelectChunks_Command.py

示例6: _update_UI_do_updates

 def _update_UI_do_updates(self):
     """
     @see: Command_PropertyManager._update_UI_do_updates()
     @see: DnaSegment_EditCommand.model_changed()
     @see: DnaSegment_EditCommand.hasResizableStructure()
     @see: self._current_model_changed_params()
     """
     
     currentParams = self._current_model_changed_params()
     
     #Optimization. Return from the model_changed method if the 
     #params are the same. 
     if same_vals(currentParams, self._previous_model_changed_params):
         return 
     
     number_of_segments, isStructResizable, why_not = currentParams
     
     #update the self._previous_model_changed_params with this new param set.
     self._previous_model_changed_params = currentParams
     
     if not isStructResizable:
         if not number_of_segments == 0:
             #disable all widgets                
             self._pmGroupBox1.setEnabled(False)
         msg = redmsg("DnaSegment is not resizable. Reason: %s"%(why_not))
         self.updateMessage(msg)
     else:
         if not self._pmGroupBox1.isEnabled():
             self._pmGroupBox1.setEnabled(True)
         msg = "Use resize handles to resize the segments"
         self.updateMessage(msg)
                 
     self.updateListWidgets() 
开发者ID:elfion,项目名称:nanoengineer,代码行数:33,代码来源:MultipleDnaSegmentResize_PropertyManager.py

示例7: do_we_need_to_recompute

 def do_we_need_to_recompute(self, context):
     """
     Do we need to recompute, now that we're in the current state
     of the given context (for purposes of current values at keys,
     as computed by self._compute_current_value)?
     """
     assert not self._recomputing
     if not self.valid:
         # following code would be wrong in this case
         return True
     for key, val in self.ordered_key_val_pairs():
         # Note: doesn't call _track_use, which would be a noop.
         newval = self._compute_current_value(key, context)
         if not same_vals(val, newval):
             #e Could optim the test for specific keys; probably not worth it
             #  though.
             #e Could optim self.before_recompute (for some callers) to leave
             #  the values cached that were already found to be the same (by
             #  prior iterations of this loop)
             # Note: We don't call self.invalidate() here, in case client
             # does nothing, current state changes, and it turns out we're
             # valid again. Clients doubting this matters and wanting to
             # optimize repeated calls of this (if they're not going to
             # recompute right away) can call it themselves. Most clients
             # needn't bother since they'll recompute right away.
             return True
     return False
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:27,代码来源:special_drawing.py

示例8: _finalizeStructure

    def _finalizeStructure(self):
        """
        Finalize the structure. This is a step just before calling Done method.
        to exit out of this command. Subclasses may overide this method
        @see: EditCommand_PM.ok_btn_clicked
        @see: DnaSegment_EditCommand where this method is overridden. 
        """
        if self.struct is None:
            return

        self.win.assy.current_command_info(cmdname=self.cmdname)

        params = self._gatherParameters()

        if not same_vals(params, self.previousParams):
            self._modifyStructure(params)

        if hasattr(self.struct, "updateCosmeticProps"):
            self.struct.updateCosmeticProps()
            self.logMessage = str(self.cmd + "Created " + self.struct.name)

        # Do we need to set the self.previousParams even when the structure
        # is finalized? I think this is unnecessary but harmless to do.
        self.previousParams = params

        self.win.assy.changed()
        self.win.win_update()
开发者ID:octopus89,项目名称:NanoEngineer-1,代码行数:27,代码来源:EditCommand.py

示例9: _update_UI_do_updates

    def _update_UI_do_updates(self):
        """
        @see: Command_PropertyManager._update_UI_do_updates()
        @see: DnaSegment_EditCommand.command_update_UI()
        @see: DnaSegment_EditCommand.hasResizableStructure()
        @see: self._current_model_changed_params()
        """

        currentParams = self._current_model_changed_params()
        
        #Optimization. Return from the model_changed method if the 
        #params are the same. 
        if same_vals(currentParams, self._previous_model_changed_params):
            return 
        

        number_of_segments, \
                          crossover_search_pref_junk,\
                          bool_valid_segmentList_junk = currentParams
                
        #update the self._previous_model_changed_params with this new param set.
        self._previous_model_changed_params = currentParams       
        #Ensures that there are only PAM3 DNA segments in the commad's tructure 
        #list (command._structList. Call this before updating the list widgets!
        self.command.ensureValidSegmentList()
        self.updateListWidgets()   
        self.command.updateCrossoverSites()
开发者ID:elfion,项目名称:nanoengineer,代码行数:27,代码来源:MakeCrossovers_PropertyManager.py

示例10: model_changed

 def model_changed(self):
     """
     Overrides basicMode.model_changed. 
     @WARNING: Ideally this property manager should implement both
            model_changed and selection_changed methods in the mode API. 
            model_changed method will be used here when the selected atom is 
            dragged, transmuted etc. The selection_changed method will be 
            used when the selection (picking/ unpicking) changes. 
            At present, selection_changed and model_changed methods are 
            called too frequently that it doesn't matter which one you use. 
            Its better to use only a single method for preformance reasons 
            (at the moment). This should change when the original 
            methods in the API are revised to be called at appropiraite 
            time. 
     """  
     newSelectionParams = self._currentSelectionParams()
     
     if same_vals(newSelectionParams, self.previousSelectionParams):
         return
     
     self.previousSelectionParams = newSelectionParams   
     #subclasses of BuildAtomsPM may not define self.selectedAtomPosGroupBox
     #so do the following check.
     if self.selectedAtomPosGroupBox:            
         self._updateSelectedAtomPosGroupBox(newSelectionParams) 
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:25,代码来源:BuildAtomsPropertyManager.py

示例11: set_constant_value

    def set_constant_value(self, val): #061117, for use in StatePlace.py
        ###e probably set_constant_value should be renamed set_value, to fit with StateRefInterface [070312]
        """#doc [for now, using this is strictly an alternative to using compute_methods --
        correctness of mixing them in one lval is not reviewed, and seems unlikely,
        with one exception: an initial compute_method can be provided for computing an initial value
        in case the value is asked for before being set, BUT IT'S AN ERROR IF THAT TRACKS ANY USAGE.
        So we enforce this by being in a variant subclass of Lval.]
        """
        # note: this is inlined into _set_defaultValue
##        if self.valid and self._value == val: # THIS HAS THE BUG of numeric arrays being == if any element is ==.
##        if self.valid and not (self._value != val): # still not correct, but more often correct, and did fix my loss-of-drag bug...
        if self.valid and same_vals(self._value, val):
            pass # important optim, but in future, we might want to only sometimes do this
                 # (eg have another variant class which doesn't do it)
        else:
            self._value = val
                # do this first, in case an outsider (violating conventions? At least for Lval, maybe not for us)
                # happens to notice self.valid being true during track_inval, so they won't be misled by an incorrect self._value
            if self.valid:
                self.track_inval() # (defined in SelfUsageTrackingMixin)
                    # WARNING: self.valid is True for us during our call of track_inval,
                    # but is False for Lval's call of it.
                    # For our call, we only need to propogate invals if we were valid
                    # (since if not, we propogated them when we became invalid, or
                    #  (more likely, assuming we're not mixing this with compute methods) [###k review re initial value compmethod]
                    #  we were never valid); but during that propogation, we'll remain valid
                    # and have our new value available (permitting queries of it during inval propogation,
                    # though that violates the convention used for the compute_method style).
                    # [#e BTW isn't track_inval misnamed, since it's really to propogate or report our inval, not to track it?]
            else:
                self.valid = True
            pass
        return
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:33,代码来源:lvals.py

示例12: _previewStructure

    def _previewStructure(self):
        """
        Preview the structure and update the previous parameters attr 
        (self.previousParams)
        @see: self.preview_or_finalize_structure
        """

        # For certain edit commands, it is possible that self.struct is
        # not created. If so simply return (don't use assert self.struct)
        ##This is a commented out stub code for the edit controllers
        ##such as DNAEditCommand which take input from the user before
        ##creating the struct. TO BE REVISED -- Ninad20071009
        # The following code is now used.  Need to improve comments and
        # some refactoring -- Ninad 2007-10-24

        if self.struct is None:
            self.struct = self._createStructure()
            self.previousParams = self._gatherParameters()
            return

        self.win.assy.current_command_info(cmdname=self.cmdname)

        params = self._gatherParameters()

        if not same_vals(params, self.previousParams):
            self._modifyStructure(params)

        self.logMessage = str(self.cmd + "Previewing " + self.struct.name)
        self.previousParams = params
        self.win.assy.changed()
        self.win.win_update()
开发者ID:octopus89,项目名称:NanoEngineer-1,代码行数:31,代码来源:EditCommand.py

示例13: model_changed

    def model_changed(self): 
        """
        @see: DnaSegment_EditCommand.model_changed()
        @see: DnaSegment_EditCommand.hasResizableStructure()
        @see: self._current_model_changed_params()
        """
        currentParams = self._current_model_changed_params()
        #Optimization. Return from the model_changed method if the 
        #params are the same. 
        if same_vals(currentParams, self._previous_model_changed_params):
            return 

        isStructResizable, why_not = currentParams
        #update the self._previous_model_changed_params with this new param set.
        self._previous_model_changed_params = currentParams

        if not isStructResizable:
            #disable all widgets
            if self._pmGroupBox1.isEnabled():
                self._pmGroupBox1.setEnabled(False)
                msg = redmsg("DnaSegment is not resizable. Reason: %s"%(why_not))
                self.updateMessage(msg)
        else:
            if not self._pmGroupBox1.isEnabled():
                self._pmGroupBox1.setEnabled(True)
                msg = "Use resize handles to resize the segment. Drag any axis or sugar"\
                    " atom for translation or rotation about axis respectively. Dragging"\
                    " any bond will freely move the whole segment."
                self.updateMessage(msg)
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:29,代码来源:DnaSegment_PropertyManager.py

示例14: done_msg

 def done_msg(self):
     'Returns the message to print after the OK button has been pressed.'
     if self.node_is_new:
         return "%s created." % self.name
     else:
         if not same_vals( self.previousParams, self.gather_parameters()):
             return "%s updated." % self.name
         else:
             return "%s unchanged." % self.name
开发者ID:ematvey,项目名称:NanoEngineer-1,代码行数:9,代码来源:PovraySceneProp.py

示例15: getAxisEndAtomAtPosition

 def getAxisEndAtomAtPosition(self, position):
     """
     Given a position, return the axis end atom at that position (if it 
     exists)
     """
     axisEndAtom = None
     endAtom1, endAtom2 = self.getAxisEndAtoms()    
     for atm in (endAtom1, endAtom2):
         if atm is not None and same_vals(position,  atm.posn()):
             axisEndAtom = atm
             break
     return axisEndAtom   
开发者ID:elfion,项目名称:nanoengineer,代码行数:12,代码来源:DnaSegment.py


注:本文中的utilities.Comparison.same_vals函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。