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


Python np.array方法代码示例

本文整理汇总了Python中pylab.np.array方法的典型用法代码示例。如果您正苦于以下问题:Python np.array方法的具体用法?Python np.array怎么用?Python np.array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pylab.np的用法示例。


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

示例1: _clicked

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def _clicked(self, event):
        if self.ignore(event):
            return
        if event.button != 1:
            return
        if event.inaxes != self.ax:
            return
        xy = self.ax.transAxes.inverted().transform_point((event.x, event.y))
        pclicked = np.array([xy[0], xy[1]])

        def inside(p):
            pcirc = np.array([p.center[0], p.center[1]])
            d = pclicked - pcirc
            return np.sqrt(np.dot(d, d)) < p.radius

        for i, (p, t) in enumerate(zip(self.circles, self.labels)):
            if t.get_window_extent().contains(event.x, event.y) or inside(p):
                self.set_active(i)
                break
        else:
            return 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:23,代码来源:widgets.py

示例2: _clicked

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def _clicked(self, event):
        if self.ignore(event):
            return
        if event.button != 1:
            return
        if event.inaxes != self.ax:
            return
        xy = self.ax.transAxes.inverted().transform_point((event.x, event.y))
        pclicked = np.array([xy[0], xy[1]])

        def inside(p):
            pcirc = np.array([p.center[0], p.center[1]])
            return dist(pclicked, pcirc) < p.radius

        for p, t in zip(self.circles, self.labels):
            if t.get_window_extent().contains(event.x, event.y) or inside(p):
                inp = p
                thist = t
                break
        else:
            return

        for p in self.circles:
            if p == inp:
                color = self.activecolor
            else:
                color = self.ax.get_axis_bgcolor()
            p.set_facecolor(color)

        if self.drawon:
            self.ax.figure.canvas.draw()

        if not self.eventson:
            return
        for cid, func in self.observers.iteritems():
            func(thist.get_text()) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:38,代码来源:widgets.py

示例3: _clicked

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def _clicked(self, event):
        if self.ignore(event):
            return
        if event.button != 1:
            return
        if event.inaxes != self.ax:
            return
        xy = self.ax.transAxes.inverted().transform_point((event.x, event.y))
        pclicked = np.array([xy[0], xy[1]])

        def inside(p):
            pcirc = np.array([p.center[0], p.center[1]])
            return dist(pclicked, pcirc) < p.radius

        for p, t in zip(self.circles, self.labels):
            if t.get_window_extent().contains(event.x, event.y) or inside(p):
                inp = p
                thist = t
                break
        else:
            return

        for p in self.circles:
            if p == inp:
                color = self.activecolor
            else:
                color = self.ax.get_axis_bgcolor()
            p.set_facecolor(color)

        if self.drawon:
            self.ax.figure.canvas.draw()

        if not self.eventson:
            return
        for cid, func in six.iteritems(self.observers):
            func(thist.get_text()) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:38,代码来源:widgets.py

示例4: set_data

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def set_data(self, pts, y=None):
        """Set x and y positions of handles"""
        if y is not None:
            x = pts
            pts = np.array([x, y])
        self._markers.set_data(pts) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:8,代码来源:widgets.py

示例5: geometry

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def geometry(self):
        """
        Returns numpy.ndarray of shape (2,5) containing
        x (``RectangleSelector.geometry[1,:]``) and
        y (``RectangleSelector.geometry[0,:]``)
        coordinates of the four corners of the rectangle starting
        and ending in the top left corner.
        """
        if hasattr(self.to_draw, 'get_verts'):
            xfm = self.ax.transData.inverted()
            y, x = xfm.transform(self.to_draw.get_verts()).T
            return np.array([x, y])
        else:
            return np.array(self.to_draw.get_data()) 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:16,代码来源:widgets.py

示例6: __init__

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def __init__(self, ax, label, image=None,
                 color='0.85', hovercolor='0.95'):
        """
        *ax*
            The :class:`matplotlib.axes.Axes` instance the button
            will be placed into.

        *label*
            The button text. Accepts string.

        *image*
            The image to place in the button, if not *None*.
            Can be any legal arg to imshow (numpy array,
            matplotlib Image instance, or PIL image).

        *color*
            The color of the button when not activated

        *hovercolor*
            The color of the button when the mouse is over it
        """
        AxesWidget.__init__(self, ax)

        if image is not None:
            ax.imshow(image)
        self.label = ax.text(0.5, 0.5, label,
                             verticalalignment='center',
                             horizontalalignment='center',
                             transform=ax.transAxes)

        self.cnt = 0
        self.observers = {}

        self.connect_event('button_press_event', self._click)
        self.connect_event('button_release_event', self._release)
        self.connect_event('motion_notify_event', self._motion)
        ax.set_navigate(False)
        ax.set_axis_bgcolor(color)
        ax.set_xticks([])
        ax.set_yticks([])
        self.color = color
        self.hovercolor = hovercolor

        self._lastcolor = color 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:46,代码来源:widgets.py

示例7: __init__

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def __init__(self, ax, label, image=None,
                 color='0.85', hovercolor='0.95'):
        """
        Parameters
        ----------
        ax : matplotlib.axes.Axes
            The :class:`matplotlib.axes.Axes` instance the button
            will be placed into.

        label : str
            The button text. Accepts string.

        image : array, mpl image, PIL image
            The image to place in the button, if not *None*.
            Can be any legal arg to imshow (numpy array,
            matplotlib Image instance, or PIL image).

        color : color
            The color of the button when not activated

        hovercolor : color
            The color of the button when the mouse is over it
        """
        AxesWidget.__init__(self, ax)

        if image is not None:
            ax.imshow(image)
        self.label = ax.text(0.5, 0.5, label,
                             verticalalignment='center',
                             horizontalalignment='center',
                             transform=ax.transAxes)

        self.cnt = 0
        self.observers = {}

        self.connect_event('button_press_event', self._click)
        self.connect_event('button_release_event', self._release)
        self.connect_event('motion_notify_event', self._motion)
        ax.set_navigate(False)
        ax.set_axis_bgcolor(color)
        ax.set_xticks([])
        ax.set_yticks([])
        self.color = color
        self.hovercolor = hovercolor

        self._lastcolor = color 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:48,代码来源:widgets.py

示例8: __init__

# 需要导入模块: from pylab import np [as 别名]
# 或者: from pylab.np import array [as 别名]
def __init__(self, ax, label, image=None,
                 color='0.85', hovercolor='0.95'):
        """
        Parameters
        ----------
        ax : matplotlib.axes.Axes
            The :class:`matplotlib.axes.Axes` instance the button
            will be placed into.

        label : str
            The button text. Accepts string.

        image : array, mpl image, Pillow Image
            The image to place in the button, if not *None*.
            Can be any legal arg to imshow (numpy array,
            matplotlib Image instance, or Pillow Image).

        color : color
            The color of the button when not activated

        hovercolor : color
            The color of the button when the mouse is over it
        """
        AxesWidget.__init__(self, ax)

        if image is not None:
            ax.imshow(image)
        self.label = ax.text(0.5, 0.5, label,
                             verticalalignment='center',
                             horizontalalignment='center',
                             transform=ax.transAxes)

        self.cnt = 0
        self.observers = {}

        self.connect_event('button_press_event', self._click)
        self.connect_event('button_release_event', self._release)
        self.connect_event('motion_notify_event', self._motion)
        ax.set_navigate(False)
        ax.set_facecolor(color)
        ax.set_xticks([])
        ax.set_yticks([])
        self.color = color
        self.hovercolor = hovercolor

        self._lastcolor = color 
开发者ID:alvarobartt,项目名称:twitter-stock-recommendation,代码行数:48,代码来源:widgets.py


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