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

williamjameshandley/py2nb: convert python scripts to jupyter notebooks

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

开源软件名称:

williamjameshandley/py2nb

开源软件地址:

https://github.com/williamjameshandley/py2nb

开源编程语言:

Python 74.9%

开源软件介绍:

py2nb: convert python scripts to jupyter notebooks

py2nb:convert python scripts to jupyter notebooks
Author: Will Handley
Version: 1.0.0
Homepage:https://github.com/williamjameshandley/py2nb
PyPi location

Description

py2nb is a python package for converting python scripts with minimal markdown to jupyter notebooks.

Markdown cells are rendered from comments beginning with #|, splits between code cells are created by comment lines beginning with #-

nb2py converts from jupyter notebooks to python

Installation

Users can install using pip:

pip install py2nb

from source:

git clone https://github.com/williamjameshandley/py2nb
cd py2nb
python setup.py install

or for those on Arch linux it is available on the AUR

Example

If one has a script named example.py containing the code:

#| # Testing ipython notebook
#| This is designed to demonstrate a simple script that converts a script into
#| a jupyter notebook with a simple additional markdown format.
#|
#| Code by default will be put into code cells
#|
#| * To make a markdown cell, prefix the comment line with with '#|' or '# |'
#| * To split a code cell, add a line beginning with '#-' or '# -'

import matplotlib.pyplot as plt
import numpy

%matplotlib inline

#| Here is a markdown cell.
#| Maths is also possible: $A=B$
#|
#| There are code cells below, split by `'#-'`:

# | Here is another markdown cell

x = numpy.random.rand(5)

#-------------------------------

y = numpy.random.rand(4)
z = numpy.random.rand(3)

#| Here are some plots

x = numpy.linspace(-2,2,1000)
y = x**3
fig, ax = plt.subplots()
ax.plot(x,y)

# -------------------------------

# | Here is another plot

x = np.linspace(-np.pi, np.pi, 201)
fig, ax = plt.subplots()
ax.plot(x,np.sin(x))

then running

py2nb example.py

produces the notebook example.ipynb

To do

  • evaluation option for script produced
  • vim syntax highlighting for markdown code blocks



鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
KarrieK/pandas_data_cleaning: A brief guide and tutorial on how to clean data us ...发布时间:2022-07-09
下一篇:
nteract/rx-jupyter: 发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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