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


Python InteractiveShellEmbed.enable_pylab方法代码示例

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


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

示例1: main

# 需要导入模块: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.frontend.terminal.embed.InteractiveShellEmbed import enable_pylab [as 别名]
def main():

    # Load the UAVO xml files in the workspace
    import taulabs
    uavo_defs = taulabs.uavo_collection.UAVOCollection()
    uavo_defs.from_uavo_xml_path('shared/uavobjectdefinition')

    # Build a new module that will make up the global namespace for the
    # interactive shell.  This allows us to restrict what the ipython shell sees.
    import imp
    user_module = imp.new_module('taulabs_env')
    user_module.__dict__.update({
            'operator'  : __import__('operator'),
            })

    # Extend the shell environment to include all of the uavo.UAVO_* classes that were
    # auto-created when the uavo xml files were processed.
    uavo_classes = [(t[0], t[1]) for t in taulabs.uavo.__dict__.iteritems() if 'UAVO_' in t[0]]
    user_module.__dict__.update(uavo_classes)

    # Build the "user" (ie. local) namespace that the interactive shell
    # will see.  These variables show up in the output of "%whos" in the shell.
    user_ns = {
        'uavo_defs' : uavo_defs,
        }

    import IPython
    from IPython.frontend.terminal.embed import InteractiveShellEmbed
    e = InteractiveShellEmbed(user_ns = user_ns, user_module = user_module)
    e.enable_pylab(import_all = True)
    e("Have a look around.  Your UAVO definitions are in 'uavo_defs'.")
开发者ID:1heinz,项目名称:TauLabs,代码行数:33,代码来源:shell.py

示例2: main

# 需要导入模块: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.frontend.terminal.embed.InteractiveShellEmbed import enable_pylab [as 别名]
def main():
    uavo_list = telemetry.get_telemetry_by_args()

    # retrieve the time from the first object.. also guarantees we can parse
    base_time = next(iter(uavo_list)).time

    # Build a new module that will make up the global namespace for the
    # interactive shell.  This allows us to restrict what the ipython shell sees.
    import imp
    user_module = imp.new_module('dronin_env')
    user_module.__dict__.update({
            'operator'  : __import__('operator'),
            'base_time' : base_time,
            })

    # Build the "user" (ie. local) namespace that the interactive shell
    # will see.  These variables show up in the output of "%whos" in the shell.
    user_ns = {
        'base_time' : base_time,
        'log_file'  : uavo_list.filename,
        'githash'   : uavo_list.githash,
        'uavo_defs' : uavo_list.uavo_defs,
        'uavo_list' : uavo_list,
        }

    # Extend the shell environment to include all of the uavo.UAVO_* classes that were
    # auto-created when the uavo xml files were processed.
    uavo_classes = [(t[0], t[1]) for t in uavo.__dict__.iteritems() if 'UAVO_' in t[0]]
    user_module.__dict__.update(uavo_classes)

    # Instantiate an ipython shell to interact with the log data.
    import IPython
    from IPython.frontend.terminal.embed import InteractiveShellEmbed
    e = InteractiveShellEmbed(user_ns = user_ns, user_module = user_module)
    e.enable_pylab(import_all = True)
    e("Analyzing log file: %s" % uavo_list.filename)
开发者ID:Trex4Git,项目名称:dRonin,代码行数:38,代码来源:shell.py

示例3: main

# 需要导入模块: from IPython.frontend.terminal.embed import InteractiveShellEmbed [as 别名]
# 或者: from IPython.frontend.terminal.embed.InteractiveShellEmbed import enable_pylab [as 别名]

#.........这里部分代码省略.........
                        # whenever the parser has completed a packet. Note that there is no checksum
                        # applied to this information so it can be totally messed up, especially if 
                        # there is a frame shift error. The internal timestamping method of UAVTalk is
                        # a much better idea.

                        from collections import namedtuple
                        LogHeader = namedtuple('LogHeader', 'time size')

                        # Read the next log record header
                        log_hdr_fmt = "<IQ"
                        log_hdr_data = fd.read(struct.calcsize(log_hdr_fmt))

                        # Check if we hit the end of the file
                        if len(log_hdr_data) == 0:
                            # Normal End of File (EOF) at a record boundary
                            break

                        # Got a log record header.  Unpack it.
                        log_hdr = LogHeader._make(struct.unpack(log_hdr_fmt, log_hdr_data))

                        # Set the baseline timestamp from the first record in the log file
                        if base_time is None:
                            base_time = log_hdr.time


                    parser.processByte(ord(fd.read(1)))

                    if parser.state == taulabs.uavtalk.UavTalk.STATE_COMPLETE:
                        if args.timestamped:
                            u  = parser.getLastReceivedObject(timestamp=log_hdr.time)
                        else:
                            u  = parser.getLastReceivedObject()
                        if u is not None:
                            uavo_parsed.append(u)

                except TypeError:
                    print "End of file"
                    break

            fd.close()

            print "Processed %d Log File Records" % len(uavo_parsed)

            print "Writing pickled log file to '%s'" % pickle_name
            import cPickle as pickle
            pickle_fd = open(pickle_name, 'wb')
            pickle.dump(githash, pickle_fd)
            pickle.dump(uavo_parsed, pickle_fd)
            pickle_fd.close()

        print "Converting log records into python objects"
        uavo_list = taulabs.uavo_list.UAVOList(uavo_defs)
        for obj_id, data, timestamp in uavo_parsed:
            obj = uavo_defs[obj_id]
            u = obj.instance_from_bytes(data, timestamp)
            uavo_list.append(u)

        # We're done with this (potentially very large) variable, delete it.
        del uavo_parsed

        # Build a new module that will make up the global namespace for the
        # interactive shell.  This allows us to restrict what the ipython shell sees.
        import imp
        user_module = imp.new_module('taulabs_env')
        user_module.__dict__.update({
                'operator'  : __import__('operator'),
                'base_time' : base_time,
                })

        # Build the "user" (ie. local) namespace that the interactive shell
        # will see.  These variables show up in the output of "%whos" in the shell.
        user_ns = {
            'base_time' : base_time,
            'log_file'  : src,
            'githash'   : githash,
            'uavo_defs' : uavo_defs,
            'uavo_list' : uavo_list,
            }

        # Extend the shell environment to include all of the uavo.UAVO_* classes that were
        # auto-created when the uavo xml files were processed.
        uavo_classes = [(t[0], t[1]) for t in taulabs.uavo.__dict__.iteritems() if 'UAVO_' in t[0]]
        user_module.__dict__.update(uavo_classes)

        if args.viewer:
            # Start the log viwer app
            from PyQt4 import QtGui
            from logviewer.gui import Window
            app = QtGui.QApplication(sys.argv)
            main = Window()
            main.show()
            main.plot(uavo_list, uavo_defs)
            sys.exit(app.exec_())
        else:
            # Instantiate an ipython shell to interact with the log data.
            import IPython
            from IPython.frontend.terminal.embed import InteractiveShellEmbed
            e = InteractiveShellEmbed(user_ns = user_ns, user_module = user_module)
            e.enable_pylab(import_all = True)
            e("Analyzing log file: %s" % src)
开发者ID:Liambeguin,项目名称:TauLabs,代码行数:104,代码来源:logview.py


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