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

Python six.iterkeys函数代码示例

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

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



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

示例1: test_Bug_2543

def test_Bug_2543():
    # Test that it possible to add all values to itself / deepcopy
    # This was not possible because validate_bool_maybe_none did not
    # accept None as an argument.
    # https://github.com/matplotlib/matplotlib/issues/2543
    # We filter warnings at this stage since a number of them are raised
    # for deprecated rcparams as they should. We dont want these in the
    # printed in the test suite.
    with warnings.catch_warnings():
        warnings.filterwarnings('ignore',
                                message='.*(deprecated|obsolete)',
                                category=UserWarning)
        with mpl.rc_context():
            _copy = mpl.rcParams.copy()
            for key in six.iterkeys(_copy):
                mpl.rcParams[key] = _copy[key]
            mpl.rcParams['text.dvipnghack'] = None
        with mpl.rc_context():
            from copy import deepcopy
            _deep_copy = deepcopy(mpl.rcParams)
        # real test is that this does not raise
        assert_true(validate_bool_maybe_none(None) is None)
        assert_true(validate_bool_maybe_none("none") is None)
        _fonttype = mpl.rcParams['svg.fonttype']
        assert_true(_fonttype == mpl.rcParams['svg.embed_char_paths'])
        with mpl.rc_context():
            mpl.rcParams['svg.embed_char_paths'] = False
            assert_true(mpl.rcParams['svg.fonttype'] == "none")
开发者ID:ChenchenYo,项目名称:matplotlib,代码行数:28,代码来源:test_rcparams.py


示例2: get_legend_handler

    def get_legend_handler(legend_handler_map, orig_handle):
        """
        return a legend handler from *legend_handler_map* that
        corresponds to *orig_handler*.

        *legend_handler_map* should be a dictionary object (that is
        returned by the get_legend_handler_map method).

        It first checks if the *orig_handle* itself is a key in the
        *legend_hanler_map* and return the associated value.
        Otherwise, it checks for each of the classes in its
        method-resolution-order. If no matching key is found, it
        returns None.
        """
        legend_handler_keys = list(six.iterkeys(legend_handler_map))
        if orig_handle in legend_handler_keys:
            handler = legend_handler_map[orig_handle]
        else:

            for handle_type in type(orig_handle).mro():
                if handle_type in legend_handler_map:
                    handler = legend_handler_map[handle_type]
                    break
            else:
                handler = None

        return handler
开发者ID:ryanbelt,项目名称:matplotlib,代码行数:27,代码来源:legend.py


示例3: comparable_formats

def comparable_formats():
    """
    Returns the list of file formats that compare_images can compare
    on this system.

    """
    return ['png'] + list(six.iterkeys(converter))
开发者ID:ADSA-UIUC,项目名称:workshop-twitter-bot,代码行数:7,代码来源:compare.py


示例4: __init__

    def __init__(self, ax, loc=None, bbox=None, **kwargs):

        Artist.__init__(self)

        if is_string_like(loc) and loc not in self.codes:
            warnings.warn('Unrecognized location %s. Falling back on '
                          'bottom; valid locations are\n%s\t' %
                          (loc, '\n\t'.join(six.iterkeys(self.codes))))
            loc = 'bottom'
        if is_string_like(loc):
            loc = self.codes.get(loc, 1)
        self.set_figure(ax.figure)
        self._axes = ax
        self._loc = loc
        self._bbox = bbox

        # use axes coords
        self.set_transform(ax.transAxes)

        self._texts = []
        self._cells = {}
        self._edges = None
        self._autoRows = []
        self._autoColumns = []
        self._autoFontsize = True
        self.update(kwargs)

        self.set_clip_on(False)

        self._cachedRenderer = None
开发者ID:Marcovaldong,项目名称:matplotlib,代码行数:30,代码来源:table.py


示例5: validate_fonttype

def validate_fonttype(s):
    """
    confirm that this is a Postscript of PDF font type that we know how to
    convert to
    """
    fonttypes = {"type3": 3, "truetype": 42}
    try:
        fonttype = validate_int(s)
    except ValueError:
        if s.lower() in six.iterkeys(fonttypes):
            return fonttypes[s.lower()]
        raise ValueError("Supported Postscript/PDF font types are %s" % list(six.iterkeys(fonttypes)))
    else:
        if fonttype not in six.itervalues(fonttypes):
            raise ValueError("Supported Postscript/PDF font types are %s" % list(six.itervalues(fonttypes)))
        return fonttype
开发者ID:zaherabdulazeez,项目名称:matplotlib,代码行数:16,代码来源:rcsetup.py


示例6: __init__

   def __init__( self, frame, sec=None, jd=None, daynum=None, dt=None ):
      """Create a new Epoch object.

      Build an epoch 1 of 2 ways:

      Using seconds past a Julian date:
      #   Epoch( 'ET', sec=1e8, jd=2451545 )

      or using a matplotlib day number
      #   Epoch( 'ET', daynum=730119.5 )


      = ERROR CONDITIONS
      - If the input units are not in the allowed list, an error is thrown.

      = INPUT VARIABLES
      - frame    The frame of the epoch.  Must be 'ET' or 'UTC'
      - sec      The number of seconds past the input JD.
      - jd       The Julian date of the epoch.
      - daynum   The matplotlib day number of the epoch.
      - dt       A python datetime instance.
      """
      if ( ( sec is None and jd is not None ) or
           ( sec is not None and jd is None ) or
           ( daynum is not None and ( sec is not None or jd is not None ) ) or
           ( daynum is None and dt is None and ( sec is None or jd is None ) ) or
           ( daynum is not None and dt is not None ) or
           ( dt is not None and ( sec is not None or jd is not None ) ) or
           ( (dt is not None) and not isinstance(dt, DT.datetime) ) ):
         msg = "Invalid inputs.  Must enter sec and jd together, " \
               "daynum by itself, or dt (must be a python datetime).\n" \
               "Sec = %s\nJD  = %s\ndnum= %s\ndt  = %s" \
               % ( str( sec ), str( jd ), str( daynum ), str( dt ) )
         raise ValueError( msg )

      if frame not in self.allowed:
         msg = "Input frame '%s' is not one of the supported frames of %s" \
               % ( frame, str( list(six.iterkeys(self.allowed) ) ) )
         raise ValueError(msg)

      self._frame = frame

      if dt is not None:
         daynum = date2num( dt )

      if daynum is not None:
         # 1-JAN-0001 in JD = 1721425.5
         jd = float( daynum ) + 1721425.5
         self._jd = math.floor( jd )
         self._seconds = ( jd - self._jd ) * 86400.0

      else:
         self._seconds = float( sec )
         self._jd = float( jd )

         # Resolve seconds down to [ 0, 86400 )
         deltaDays = int( math.floor( self._seconds / 86400.0 ) )
         self._jd += deltaDays
         self._seconds -= deltaDays * 86400.0
开发者ID:ethanhelfman,项目名称:InstaGet,代码行数:59,代码来源:Epoch.py


示例7: get_projection_names

 def get_projection_names(self):
     """
     Get a list of the names of all projections currently
     registered.
     """
     names = list(six.iterkeys(self._all_projection_types))
     names.sort()
     return names
开发者ID:717524640,项目名称:matplotlib,代码行数:8,代码来源:__init__.py


示例8: _get_grid_bbox

    def _get_grid_bbox(self, renderer):
        """Get a bbox, in axes co-ordinates for the cells.

        Only include those in the range (0,0) to (maxRow, maxCol)"""
        boxes = [self._cells[pos].get_window_extent(renderer)
                 for pos in six.iterkeys(self._cells)
                 if pos[0] >= 0 and pos[1] >= 0]

        bbox = Bbox.union(boxes)
        return bbox.inverse_transformed(self.get_transform())
开发者ID:Marcovaldong,项目名称:matplotlib,代码行数:10,代码来源:table.py


示例9: test_colormap_reversing

def test_colormap_reversing():
    """Check the generated _lut data of a colormap and corresponding
    reversed colormap if they are almost the same."""
    for name in six.iterkeys(cm.cmap_d):
        cmap = plt.get_cmap(name)
        cmap_r = cmap.reversed()
        if not cmap_r._isinit:
            cmap._init()
            cmap_r._init()
        assert_array_almost_equal(cmap._lut[:-3], cmap_r._lut[-4::-1])
开发者ID:bastibe,项目名称:matplotlib,代码行数:10,代码来源:test_colors.py


示例10: __init__

 def __init__(self, scale, tfm, texname, vf):
     if six.PY3 and isinstance(texname, bytes):
         texname = texname.decode('ascii')
     self._scale, self._tfm, self.texname, self._vf = \
         scale, tfm, texname, vf
     self.size = scale * (72.0 / (72.27 * 2**16))
     try:
         nchars = max(six.iterkeys(tfm.width)) + 1
     except ValueError:
         nchars = 0
     self.widths = [(1000*tfm.width.get(char, 0)) >> 20
                    for char in xrange(nchars)]
开发者ID:phametus,项目名称:matplotlib,代码行数:12,代码来源:dviread.py


示例11: checkUnits

   def checkUnits( self, units ):
      """Check to see if some units are valid.

      = ERROR CONDITIONS
      - If the input units are not in the allowed list, an error is thrown.

      = INPUT VARIABLES
      - units    The string name of the units to check.
      """
      if units not in self.allowed:
         msg = "Input units '%s' are not one of the supported types of %s" \
               % ( units, str( list(six.iterkeys(self.allowed)) ) )
         raise ValueError( msg )
开发者ID:717524640,项目名称:matplotlib,代码行数:13,代码来源:UnitDbl.py


示例12: aliased_name

    def aliased_name(self, s):
        """
        return 'PROPNAME or alias' if *s* has an alias, else return
        PROPNAME.

        e.g., for the line markerfacecolor property, which has an
        alias, return 'markerfacecolor or mfc' and for the transform
        property, which does not, return 'transform'
        """

        if s in self.aliasd:
            return s + "".join([" or %s" % x for x in six.iterkeys(self.aliasd[s])])
        else:
            return s
开发者ID:fonnesbeck,项目名称:matplotlib,代码行数:14,代码来源:artist.py


示例13: test_RcParams_class

def test_RcParams_class():
    rc = mpl.RcParams(
        {
            "font.cursive": ["Apple Chancery", "Textile", "Zapf Chancery", "cursive"],
            "font.family": "sans-serif",
            "font.weight": "normal",
            "font.size": 12,
        }
    )

    if six.PY3:
        expected_repr = """
RcParams({'font.cursive': ['Apple Chancery',
                           'Textile',
                           'Zapf Chancery',
                           'cursive'],
          'font.family': ['sans-serif'],
          'font.size': 12.0,
          'font.weight': 'normal'})""".lstrip()
    else:
        expected_repr = """
RcParams({u'font.cursive': [u'Apple Chancery',
                            u'Textile',
                            u'Zapf Chancery',
                            u'cursive'],
          u'font.family': [u'sans-serif'],
          u'font.size': 12.0,
          u'font.weight': u'normal'})""".lstrip()

    assert_str_equal(expected_repr, repr(rc))

    if six.PY3:
        expected_str = """
font.cursive: ['Apple Chancery', 'Textile', 'Zapf Chancery', 'cursive']
font.family: ['sans-serif']
font.size: 12.0
font.weight: normal""".lstrip()
    else:
        expected_str = """
font.cursive: [u'Apple Chancery', u'Textile', u'Zapf Chancery', u'cursive']
font.family: [u'sans-serif']
font.size: 12.0
font.weight: normal""".lstrip()

    assert_str_equal(expected_str, str(rc))

    # test the find_all functionality
    assert ["font.cursive", "font.size"] == sorted(rc.find_all("i[vz]").keys())
    assert ["font.family"] == list(six.iterkeys(rc.find_all("family")))
开发者ID:rmorshea,项目名称:matplotlib,代码行数:49,代码来源:test_rcparams.py


示例14: _do_cell_alignment

    def _do_cell_alignment(self):
        """ Calculate row heights and column widths.

        Position cells accordingly.
        """
        # Calculate row/column widths
        widths = {}
        heights = {}
        for (row, col), cell in six.iteritems(self._cells):
            height = heights.setdefault(row, 0.0)
            heights[row] = max(height, cell.get_height())
            width = widths.setdefault(col, 0.0)
            widths[col] = max(width, cell.get_width())

        # work out left position for each column
        xpos = 0
        lefts = {}
        cols = list(six.iterkeys(widths))
        cols.sort()
        for col in cols:
            lefts[col] = xpos
            xpos += widths[col]

        ypos = 0
        bottoms = {}
        rows = list(six.iterkeys(heights))
        rows.sort()
        rows.reverse()
        for row in rows:
            bottoms[row] = ypos
            ypos += heights[row]

        # set cell positions
        for (row, col), cell in six.iteritems(self._cells):
            cell.set_x(lefts[col])
            cell.set_y(bottoms[row])
开发者ID:Marcovaldong,项目名称:matplotlib,代码行数:36,代码来源:table.py


示例15: aliased_name_rest

    def aliased_name_rest(self, s, target):
        """
        return 'PROPNAME or alias' if *s* has an alias, else return
        PROPNAME formatted for ReST

        e.g., for the line markerfacecolor property, which has an
        alias, return 'markerfacecolor or mfc' and for the transform
        property, which does not, return 'transform'
        """

        if s in self.aliasd:
            aliases = "".join([" or %s" % x for x in six.iterkeys(self.aliasd[s])])
        else:
            aliases = ""
        return ":meth:`%s <%s>`%s" % (s, target, aliases)
开发者ID:fonnesbeck,项目名称:matplotlib,代码行数:15,代码来源:artist.py


示例16: win32InstalledFonts

def win32InstalledFonts(directory=None, fontext="ttf"):
    """
    Search for fonts in the specified font directory, or use the
    system directories if none given.  A list of TrueType font
    filenames are returned by default, or AFM fonts if *fontext* ==
    'afm'.
    """

    from matplotlib.externals.six.moves import winreg

    if directory is None:
        directory = win32FontDirectory()

    fontext = get_fontext_synonyms(fontext)

    key, items = None, {}
    for fontdir in MSFontDirectories:
        try:
            local = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, fontdir)
        except OSError:
            continue

        if not local:
            return list_fonts(directory, fontext)
        try:
            for j in range(winreg.QueryInfoKey(local)[1]):
                try:
                    key, direc, any = winreg.EnumValue(local, j)
                    if not is_string_like(direc):
                        continue
                    if not os.path.dirname(direc):
                        direc = os.path.join(directory, direc)
                    direc = os.path.abspath(direc).lower()
                    if os.path.splitext(direc)[1][1:] in fontext:
                        items[direc] = 1
                except EnvironmentError:
                    continue
                except WindowsError:
                    continue
                except MemoryError:
                    continue
            return list(six.iterkeys(items))
        finally:
            winreg.CloseKey(local)
    return None
开发者ID:Qiaozi,项目名称:matplotlib,代码行数:45,代码来源:font_manager.py


示例17: contains

    def contains(self, mouseevent):
        """Test whether the mouse event occurred in the table.

        Returns T/F, {}
        """
        if six.callable(self._contains):
            return self._contains(self, mouseevent)

        # TODO: Return index of the cell containing the cursor so that the user
        # doesn't have to bind to each one individually.
        if self._cachedRenderer is not None:
            boxes = [self._cells[pos].get_window_extent(self._cachedRenderer)
                     for pos in six.iterkeys(self._cells)
                     if pos[0] >= 0 and pos[1] >= 0]
            bbox = Bbox.union(boxes)
            return bbox.contains(mouseevent.x, mouseevent.y), {}
        else:
            return False, {}
开发者ID:Marcovaldong,项目名称:matplotlib,代码行数:18,代码来源:table.py


示例18: draw_markers

    def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None):
        if not len(path.vertices):
            return

        writer = self.writer
        path_data = self._convert_path(
            marker_path,
            marker_trans + Affine2D().scale(1.0, -1.0),
            simplify=False)
        style = self._get_style_dict(gc, rgbFace)
        dictkey = (path_data, generate_css(style))
        oid = self._markers.get(dictkey)
        for key in list(six.iterkeys(style)):
            if not key.startswith('stroke'):
                del style[key]
        style = generate_css(style)

        if oid is None:
            oid = self._make_id('m', dictkey)
            writer.start('defs')
            writer.element('path', id=oid, d=path_data, style=style)
            writer.end('defs')
            self._markers[dictkey] = oid

        attrib = {}
        clipid = self._get_clip(gc)
        if clipid is not None:
            attrib['clip-path'] = 'url(#%s)' % clipid
        writer.start('g', attrib=attrib)

        trans_and_flip = self._make_flip_transform(trans)
        attrib = {'xlink:href': '#%s' % oid}
        clip = (0, 0, self.width*72, self.height*72)
        for vertices, code in path.iter_segments(
                trans_and_flip, clip=clip, simplify=False):
            if len(vertices):
                x, y = vertices[-2:]
                attrib['x'] = short_float_fmt(x)
                attrib['y'] = short_float_fmt(y)
                attrib['style'] = self._get_style(gc, rgbFace)
                writer.element('use', attrib=attrib)
        writer.end('g')
开发者ID:ChenchenYo,项目名称:matplotlib,代码行数:42,代码来源:backend_svg.py


示例19: pprint_getters

    def pprint_getters(self):
        """
        Return the getters and actual values as list of strings.
        """

        d = self.properties()
        names = list(six.iterkeys(d))
        names.sort()
        lines = []
        for name in names:
            val = d[name]
            if getattr(val, "shape", ()) != () and len(val) > 6:
                s = str(val[:6]) + "..."
            else:
                s = str(val)
            s = s.replace("\n", " ")
            if len(s) > 50:
                s = s[:50] + "..."
            name = self.aliased_name(name)
            lines.append("    %s = %s" % (name, s))
        return lines
开发者ID:fonnesbeck,项目名称:matplotlib,代码行数:21,代码来源:artist.py


示例20: findSystemFonts

def findSystemFonts(fontpaths=None, fontext='ttf'):
    """
    Search for fonts in the specified font paths.  If no paths are
    given, will use a standard set of system paths, as well as the
    list of fonts tracked by fontconfig if fontconfig is installed and
    available.  A list of TrueType fonts are returned by default with
    AFM fonts as an option.
    """
    fontfiles = {}
    fontexts = get_fontext_synonyms(fontext)

    if fontpaths is None:
        if sys.platform == 'win32':
            fontdir = win32FontDirectory()

            fontpaths = [fontdir]
            # now get all installed fonts directly...
            for f in win32InstalledFonts(fontdir):
                base, ext = os.path.splitext(f)
                if len(ext)>1 and ext[1:].lower() in fontexts:
                    fontfiles[f] = 1
        else:
            fontpaths = X11FontDirectories
            # check for OS X & load its fonts if present
            if sys.platform == 'darwin':
                for f in OSXInstalledFonts(fontext=fontext):
                    fontfiles[f] = 1

            for f in get_fontconfig_fonts(fontext):
                fontfiles[f] = 1

    elif isinstance(fontpaths, six.string_types):
        fontpaths = [fontpaths]

    for path in fontpaths:
        files = list_fonts(path, fontexts)
        for fname in files:
            fontfiles[os.path.abspath(fname)] = 1

    return [fname for fname in six.iterkeys(fontfiles) if os.path.exists(fname)]
开发者ID:NishantMF,项目名称:matplotlib,代码行数:40,代码来源:font_manager.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python six.itervalues函数代码示例发布时间:2022-05-27
下一篇:
Python six.iteritems函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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