python类int()的实例源码

numerictypes.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def issubclass_(arg1, arg2):
    """
    Determine if a class is a subclass of a second class.

    `issubclass_` is equivalent to the Python built-in ``issubclass``,
    except that it returns False instead of raising a TypeError if one
    of the arguments is not a class.

    Parameters
    ----------
    arg1 : class
        Input class. True is returned if `arg1` is a subclass of `arg2`.
    arg2 : class or tuple of classes.
        Input class. If a tuple of classes, True is returned if `arg1` is a
        subclass of any of the tuple elements.

    Returns
    -------
    out : bool
        Whether `arg1` is a subclass of `arg2` or not.

    See Also
    --------
    issubsctype, issubdtype, issctype

    Examples
    --------
    >>> np.issubclass_(np.int32, np.int)
    True
    >>> np.issubclass_(np.int32, np.float)
    False

    """
    try:
        return issubclass(arg1, arg2)
    except TypeError:
        return False
numerictypes.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def issubsctype(arg1, arg2):
    """
    Determine if the first argument is a subclass of the second argument.

    Parameters
    ----------
    arg1, arg2 : dtype or dtype specifier
        Data-types.

    Returns
    -------
    out : bool
        The result.

    See Also
    --------
    issctype, issubdtype,obj2sctype

    Examples
    --------
    >>> np.issubsctype('S8', str)
    True
    >>> np.issubsctype(np.array([1]), np.int)
    True
    >>> np.issubsctype(np.array([1]), np.float)
    False

    """
    return issubclass(obj2sctype(arg1), obj2sctype(arg2))
_iotools.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def flatten_dtype(ndtype, flatten_base=False):
    """
    Unpack a structured data-type by collapsing nested fields and/or fields
    with a shape.

    Note that the field names are lost.

    Parameters
    ----------
    ndtype : dtype
        The datatype to collapse
    flatten_base : {False, True}, optional
        Whether to transform a field with a shape into several fields or not.

    Examples
    --------
    >>> dt = np.dtype([('name', 'S4'), ('x', float), ('y', float),
    ...                ('block', int, (2, 3))])
    >>> np.lib._iotools.flatten_dtype(dt)
    [dtype('|S4'), dtype('float64'), dtype('float64'), dtype('int32')]
    >>> np.lib._iotools.flatten_dtype(dt, flatten_base=True)
    [dtype('|S4'), dtype('float64'), dtype('float64'), dtype('int32'),
     dtype('int32'), dtype('int32'), dtype('int32'), dtype('int32'),
     dtype('int32')]

    """
    names = ndtype.names
    if names is None:
        if flatten_base:
            return [ndtype.base] * int(np.prod(ndtype.shape))
        return [ndtype.base]
    else:
        types = []
        for field in names:
            info = ndtype.fields[field]
            flat_dt = flatten_dtype(info[0], flatten_base)
            types.extend(flat_dt)
        return types
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle_include(self, span, fname):
        '''Called when parser starts to process a new file.

        It is a dummy methond and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the include directive
                or None if called the first time for the main input.
            fname (str): Name of the file.
        '''
        self._log_event('include', span, filename=fname)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handle_endinclude(self, span, fname):
        '''Called when parser finished processing a file.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the include directive
                or None if called the first time for the main input.
            fname (str): Name of the file.
        '''
        self._log_event('endinclude', span, filename=fname)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def handle_set(self, span, name, expr):
        '''Called when parser encounters a set directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str): Name of the variable.
            expr (str): String representation of the expression to be assigned
                to the variable.
        '''
        self._log_event('set', span, name=name, expression=expr)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle_def(self, span, name, args):
        '''Called when parser encounters a def directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str): Name of the macro to be defined.
            argexpr (str): String with argument definition (or None)
        '''
        self._log_event('def', span, name=name, arguments=args)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle_enddef(self, span, name):
        '''Called when parser encounters an enddef directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str): Name found after the enddef directive.
        '''
        self._log_event('enddef', span, name=name)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def handle_if(self, span, cond):
        '''Called when parser encounters an if directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            cond (str): String representation of the branching condition.
        '''
        self._log_event('if', span, condition=cond)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_elif(self, span, cond):
        '''Called when parser encounters an elif directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            cond (str): String representation of the branching condition.
        '''
        self._log_event('elif', span, condition=cond)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_else(self, span):
        '''Called when parser encounters an else directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
        '''
        self._log_event('else', span)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def handle_endif(self, span):
        '''Called when parser encounters an endif directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
        '''
        self._log_event('endif', span)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handle_for(self, span, varexpr, iterator):
        '''Called when parser encounters a for directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            varexpr (str): String representation of the loop variable
                expression.
            iterator (str): String representation of the iterable.
        '''
        self._log_event('for', span, variable=varexpr, iterable=iterator)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_call(self, span, name, argexpr):
        '''Called when parser encounters a call directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str): Name of the callable to call
            argexpr (str or None): Argument expression containing additional
                arguments for the call.
        '''
        self._log_event('call', span, name=name, argexpr=argexpr)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def handle_nextarg(self, span, name):
        '''Called when parser encounters a nextarg directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str or None): Name of the argument following next or
                None if it should be the next positional argument.
        '''
        self._log_event('nextarg', span, name=name)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_endcall(self, span, name):
        '''Called when parser encounters an endcall directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str): Name found after the endcall directive.
        '''
        self._log_event('endcall', span, name=name)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def handle_eval(self, span, expr):
        '''Called when parser encounters an eval directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            expr (str): String representation of the Python expression to
                be evaluated.
        '''
        self._log_event('eval', span, expression=expr)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_global(self, span, name):
        '''Called when parser encounters a global directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
            name (str): Name of the variable which should be made global.
        '''
        self._log_event('global', span, name=name)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def handle_comment(self, span):
        '''Called when parser finds a preprocessor comment.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
        '''
        self._log_event('comment', span)
fypp.py 文件源码 项目:fypp 作者: aradi 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def handle_mute(self, span):
        '''Called when parser finds a mute directive.

        It is a dummy method and should be overriden for actual use.

        Args:
            span (tuple of int): Start and end line of the directive.
        '''
        self._log_event('mute', span)


问题


面经


文章

微信
公众号

扫码关注公众号