• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python attributetools.setWithOperation函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setOris

    def setOris(self,value,operation='', log=True):
        """Set the orientation for each element.
        Should either be a single value or an Nx1 array/list
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)

        #check shape
        if value.shape in [(),(1,)]:
            value = value.repeat(self.nElements)
        elif value.shape in [(self.nElements,), (self.nElements,1)]:
            pass #is already Nx1
        else:
            raise ValueError("New value for setOris should be either Nx1 or a single value")

        # flip orientation so, when drawn, it matches the convention of other
        # visual stimuli
        value = -value

        #set value
        setWithOperation(self, 'oris', value, operation)

        self.needVertexUpdate=True
        if log and self.autoLog:
            self.win.logOnFlip("Set %s oris=%s" %(self.name, type(value)),
                level=logging.EXP,obj=self)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:27,代码来源:elementarray.py


示例2: setSizes

    def setSizes(self,value,operation='', log=True):
        """Set the size for each element.
        Should either be:

          - a single value
          - an Nx1 array/list
          - an Nx2 array/list
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        #check shape
        if value.shape in [(),(1,),(2,)]:
            value = numpy.resize(value, [self.nElements,2])
        elif value.shape in [(self.nElements,), (self.nElements,1)]:
            value.shape=(self.nElements,1)#set to be 2D
            value = value.repeat(2,1) #repeat once on dim 1
        elif value.shape == (self.nElements,2):
            pass#all is good
        else:
            raise ValueError("New value for setSizes should be either Nx1, Nx2 or a single value")

        #set value and log
        setWithOperation(self, 'sizes', value, operation)
        logAttrib(self, log, 'sizes', type(value))
        self._needVertexUpdate=True
        self._needTexCoordUpdate=True
开发者ID:del82,项目名称:psychopy,代码行数:27,代码来源:elementarray.py


示例3: setSfs

    def setSfs(self, value,operation='', log=True):
        """Set the spatial frequency for each element.
        Should either be:

          - a single value
          - an Nx1 array/list
          - an Nx2 array/list (spatial frequency of the element in X and Y).

        If the units for the stimulus are 'pix' or 'norm' then the units of sf
        are cycles per stimulus width. For units of 'deg' or 'cm' the units
        are c/cm or c/deg respectively.

        """

        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)

        #check shape
        if value.shape in [(),(1,),(2,)]:
            value = numpy.resize(value, [self.nElements,2])
        elif value.shape in [(self.nElements,), (self.nElements,1)]:
            value.shape=(self.nElements,1)#set to be 2D
            value = value.repeat(2,1) #repeat once on dim 1
        elif value.shape == (self.nElements,2):
            pass#all is good
        else:
            raise ValueError("New value for setSfs should be either Nx1, Nx2 or a single value")

        # Set value and log
        setWithOperation(self, 'sfs', value, operation)
        if log and self.autoLog:
            self.win.logOnFlip("Set %s sfs=%s" %(self.name, type(value)),
                level=logging.EXP,obj=self)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:34,代码来源:elementarray.py


示例4: setPhases

    def setPhases(self,value,operation='', log=True):
        """Set the phase for each element.
        Should either be:

          - a single value
          - an Nx1 array/list
          - an Nx2 array/list (for separate X and Y phase)
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)

        #check shape
        if value.shape in [(),(1,),(2,)]:
            value = numpy.resize(value, [self.nElements,2])
        elif value.shape in [(self.nElements,), (self.nElements,1)]:
            value.shape=(self.nElements,1)#set to be 2D
            value = value.repeat(2,1) #repeat once on dim 1
        elif value.shape == (self.nElements,2):
            pass#all is good
        else:
            raise ValueError("New value for setPhases should be either Nx1, Nx2 or a single value")

        #set value and log
        setWithOperation(self, 'phases', value, operation)
        self.needTexCoordUpdate=True

        if log and self.autoLog:
            self.win.logOnFlip("Set %s phases=%s" %(self.name, type(value)),
                level=logging.EXP,obj=self)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:30,代码来源:elementarray.py


示例5: setContrs

    def setContrs(self,value,operation='', log=True):
        """Set the contrast for each element.
        Should either be:

          - a single value
          - an Nx1 array/list
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        #check shape
        if value.shape in [(),(1,)]:
            value = value.repeat(self.nElements)
        elif value.shape in [(self.nElements,), (self.nElements,1)]:
            pass #is already Nx1
        else:
            raise ValueError("New value for setContrs should be either Nx1 or a single value")

        #set value and log
        setWithOperation(self, 'contrs', value, operation)
        self.needColorUpdate=True

        if log and self.autoLog:
            self.win.logOnFlip("Set %s contrs=%s" %(self.name, type(value)),
                level=logging.EXP,obj=self)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:25,代码来源:elementarray.py


示例6: setSfs

    def setSfs(self, value, operation="", log=True):
        """Set the spatial frequency for each element.
        Should either be:

          - a single value
          - an Nx1 array/list
          - an Nx2 array/list (spatial frequency of the element in X and Y).

        If the units for the stimulus are 'pix' or 'norm' then the units of sf
        are cycles per stimulus width. For units of 'deg' or 'cm' the units
        are c/cm or c/deg respectively.

        """

        # make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)

        # check shape
        if value.shape in [(), (1,), (2,)]:
            value = numpy.resize(value, [self.nElements, 2])
        elif value.shape in [(self.nElements,), (self.nElements, 1)]:
            value.shape = (self.nElements, 1)  # set to be 2D
            value = value.repeat(2, 1)  # repeat once on dim 1
        elif value.shape == (self.nElements, 2):
            pass  # all is good
        else:
            raise ValueError("New value for setSfs should be either Nx1, Nx2 or a single value")

        # Set value and log
        setWithOperation(self, "sfs", value, operation)
        logAttrib(self, log, "sfs", type(value))
        self._needTexCoordUpdate = True
开发者ID:kastman,项目名称:psychopy,代码行数:33,代码来源:elementarray.py


示例7: _set

    def _set(self, attrib, val, op='', log=True):
        """Use this to set attributes of your stimulus after initialising it.

        :Parameters:

        attrib : a string naming any of the attributes of the stimulus (set during init)
        val : the value to be used in the operation on the attrib
        op : a string representing the operation to be performed (optional) most maths operators apply ('+','-','*'...)

        examples::

            myStim.set('rgb',0) #will simply set all guns to zero (black)
            myStim.set('rgb',0.5,'+') #will increment all 3 guns by 0.5
            myStim.set('rgb',(1.0,0.5,0.5),'*') # will keep the red gun the same and halve the others

        """
        #format the input value as float vectors
        if type(val) in [tuple,list]:
            val=numpy.array(val,float)

        #change the attribute as requested
        setWithOperation(self, attrib, val, op)

        #update the actual coherence for the requested coherence and nDots
        if attrib in ['nDots','coherence']:
            self.coherence=round(self.coherence*self.nDots)/self.nDots

        if log and self.autoLog:
            self.win.logOnFlip("Set %s %s=%s" %(self.name, attrib, getattr(self,attrib)),
                level=logging.EXP)
开发者ID:PieterMoors,项目名称:psychopy,代码行数:30,代码来源:dot.py


示例8: setFieldPos

    def setFieldPos(self,value,operation='', log=True):
        """Set the centre of the array (X,Y)
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        #check shape
        if value.shape != (2,):
            raise ValueError("New value for setFieldPos should be [x,y]")

        #set value and log
        setWithOperation(self, 'fieldPos', value, operation)
        logAttrib(self, log, 'fieldPos', type(value))
开发者ID:del82,项目名称:psychopy,代码行数:13,代码来源:elementarray.py


示例9: setFieldSize

    def setFieldSize(self,value,operation='', log=True):
        """Set the size of the array on the screen (will override
        current XY positions of the elements)
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        #check shape
        if value.shape not in [(2,),(1,)]:
            raise ValueError("New value for setFieldSize should be [x,y] or a single value")

        #set value and log
        setWithOperation(self, 'fieldSize', value, operation)
        logAttrib(self, log, 'fieldSize')
        self.setXYs(log=False)#to reflect new settings, overriding individual xys
开发者ID:del82,项目名称:psychopy,代码行数:15,代码来源:elementarray.py


示例10: setFieldPos

    def setFieldPos(self,value,operation='', log=True):
        """Set the centre of the array (X,Y)
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        #check shape
        if value.shape != (2,):
            raise ValueError("New value for setFieldPos should be [x,y]")

        #set value and log
        setWithOperation(self, 'fieldPos', value, operation)

        if log and self.autoLog:
            self.win.logOnFlip("Set %s fieldPos=%s" %(self.name, type(value)),
                level=logging.EXP,obj=self)
开发者ID:rpbaxter,项目名称:psychopy,代码行数:16,代码来源:elementarray.py


示例11: setVertices

    def setVertices(self, value=None, operation="", log=True):
        """Set the xy values of the vertices (relative to the centre of the field).
        Values should be:

            - an array/list of Nx2 coordinates.

        """
        # make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        # check shape
        if not (value.shape == (2,) or (len(value.shape) == 2 and value.shape[1] == 2)):
            raise ValueError("New value for setXYs should be 2x1 or Nx2")
        # set value and log
        setWithOperation(self, "vertices", value, operation)
        logAttrib(self, log, "vertices", value)
        self._needVertexUpdate = True
开发者ID:hanke,项目名称:psychopy,代码行数:17,代码来源:shape.py


示例12: _set

    def _set(self, attrib, val, op='', log=True):
        """
        Use this method when you want to be able to suppress logging (e.g., in
        tests). Typically better to use methods specific to the parameter, e.g. ::

             stim.pos = [3,2.5]
             stim.ori = 45
             stim.phase += 0.5

        NB this method does not flag the need for updates any more - that is
        done by specific methods as described above.
        """
        if op==None: op=''
        #format the input value as float vectors
        if type(val) in [tuple, list, numpy.ndarray]:
            val = val2array(val)
        # Handle operations
        setWithOperation(self, attrib, val, op)
开发者ID:BrainTech,项目名称:psychopy,代码行数:18,代码来源:basevisual.py


示例13: setXYs

    def setXYs(self, value=None, operation="", log=True):
        """Set the xy values of the element centres (relative to the centre of the field).
        Values should be:

            - None
            - an array/list of Nx2 coordinates.

        If value is None then the xy positions will be generated automatically, based
        on the fieldSize and fieldPos. In this case opacity will also be overridden
        by this function (it is used to make elements outside the field invisible.
        """
        if value == None:
            if self.fieldShape in ["sqr", "square"]:
                self.xys = (
                    numpy.random.rand(self.nElements, 2) * self.fieldSize - self.fieldSize / 2
                )  # initialise a random array of X,Y
                # gone outside the square
                self.xys[:, 0] = ((self.xys[:, 0] + self.fieldSize[0] / 2) % self.fieldSize[0]) - self.fieldSize[0] / 2
                self.xys[:, 1] = ((self.xys[:, 1] + self.fieldSize[1] / 2) % self.fieldSize[1]) - self.fieldSize[1] / 2
            elif self.fieldShape is "circle":
                # take twice as many elements as we need (and cull the ones outside the circle)
                xys = (
                    numpy.random.rand(self.nElements * 2, 2) * self.fieldSize - self.fieldSize / 2
                )  # initialise a random array of X,Y
                # gone outside the square
                xys[:, 0] = ((xys[:, 0] + self.fieldSize[0] / 2) % self.fieldSize[0]) - self.fieldSize[0] / 2
                xys[:, 1] = ((xys[:, 1] + self.fieldSize[1] / 2) % self.fieldSize[1]) - self.fieldSize[1] / 2
                # use a circular envelope and flips dot to opposite edge if they fall
                # beyond radius.
                # NB always circular - uses fieldSize in X only
                normxy = xys / (self.fieldSize / 2.0)
                dotDist = numpy.sqrt((normxy[:, 0] ** 2.0 + normxy[:, 1] ** 2.0))
                self.xys = xys[dotDist < 1.0, :][0 : self.nElements]
        else:
            # make into an array
            if type(value) in [int, float, list, tuple]:
                value = numpy.array(value, dtype=float)
            # check shape
            if not (value.shape in [(), (2,), (self.nElements, 2)]):
                raise ValueError("New value for setXYs should be either None or Nx2")
            # set value
            setWithOperation(self, "xys", value, operation)
        self._needVertexUpdate = True
        logAttrib(self, log, "XYs", type(value))
开发者ID:kastman,项目名称:psychopy,代码行数:44,代码来源:elementarray.py


示例14: setOpacities

    def setOpacities(self,value,operation='', log=True):
        """Set the opacity for each element.
        Should either be a single value or an Nx1 array/list
        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)

        #check shape
        if value.shape in [(),(1,)]:
            value = value.repeat(self.nElements)
        elif value.shape in [(self.nElements,), (self.nElements,1)]:
            pass #is already Nx1
        else:
            raise ValueError("New value for setOpacities should be either Nx1 or a single value")

        #set value and log
        setWithOperation(self, 'opacities', value, operation)
        logAttrib(self, log, 'opacities', type(value))
开发者ID:del82,项目名称:psychopy,代码行数:19,代码来源:elementarray.py


示例15: _set

    def _set(self, attrib, val, op='', log=True):
        """
        Deprecated. Use methods specific to the parameter you want to set

        e.g. ::

             stim.pos = [3,2.5]
             stim.ori = 45
             stim.phase += 0.5

        NB this method does not flag the need for updates any more - that is
        done by specific methods as described above.
        """
        if op==None: op=''
        #format the input value as float vectors
        if type(val) in (tuple, list):
            val=numpy.array(val, float)

        setWithOperation(self, attrib, val, op)
        logAttrib(self, log, attrib)
开发者ID:9173860,项目名称:psychopy,代码行数:20,代码来源:simpleimage.py


示例16: setOris

    def setOris(self, value, operation="", log=True):
        """Set the orientation for each element.
        Should either be a single value or an Nx1 array/list
        """
        # make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)

        # check shape
        if value.shape in [(), (1,)]:
            value = value.repeat(self.nElements)
        elif value.shape in [(self.nElements,), (self.nElements, 1)]:
            pass  # is already Nx1
        else:
            raise ValueError("New value for setOris should be either Nx1 or a single value")

        # set value
        setWithOperation(self, "oris", value, operation)
        logAttrib(self, log, "oris", type(value))
        self._needVertexUpdate = True
开发者ID:kastman,项目名称:psychopy,代码行数:20,代码来源:elementarray.py


示例17: setVertices

    def setVertices(self,value=None, operation='', log=True):
        """Set the xy values of the vertices (relative to the centre of the field).
        Values should be:

            - an array/list of Nx2 coordinates.

        """
        #make into an array
        if type(value) in [int, float, list, tuple]:
            value = numpy.array(value, dtype=float)
        #check shape
        if not (value.shape==(2,) \
            or (len(value.shape)==2 and value.shape[1]==2)
            ):
                raise ValueError("New value for setXYs should be 2x1 or Nx2")
        #set value and log
        setWithOperation(self, 'vertices', value, operation)
        self.needVertexUpdate=True

        if log and self.autoLog:
            self.win.logOnFlip("Set %s vertices=%s" %(self.name, value),
                level=logging.EXP,obj=self)
开发者ID:frankpapenmeier,项目名称:psychopy,代码行数:22,代码来源:shape.py


示例18: _set

    def _set(self, attrib, val, op='', log=True):
        """
        Deprecated. Use methods specific to the parameter you want to set

        e.g. ::

             stim.pos = [3,2.5]
             stim.ori = 45
             stim.phase += 0.5

        NB this method does not flag the need for updates any more - that is
        done by specific methods as described above.
        """
        if op==None: op=''
        #format the input value as float vectors
        if type(val) in (tuple, list):
            val=numpy.array(val, float)

        setWithOperation(self, attrib, val, op)

        if log and self.autoLog:
            self.win.logOnFlip("Set %s %s=%s" %(self.name, attrib, getattr(self,attrib)),
                level=logging.EXP,obj=self)
开发者ID:GentBinaku,项目名称:psychopy,代码行数:23,代码来源:simpleimage.py


示例19: setFieldCoherence

 def setFieldCoherence(self, val, op="", log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setWithOperation(self, "coherence", val, op, autoLog=log)  # calls attributeSetter
开发者ID:kastman,项目名称:psychopy,代码行数:5,代码来源:dot.py


示例20: setSpeed

 def setSpeed(self, val, op="", log=True):
     """Usually you can use 'stim.attribute = value' syntax instead,
     but use this method if you need to suppress the log message
     """
     setWithOperation(self, "speed", val, op, autoLog=log)
开发者ID:kastman,项目名称:psychopy,代码行数:5,代码来源:dot.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python filetools.fromFile函数代码示例发布时间:2022-05-25
下一篇:
Python attributetools.setAttribute函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap