Skip to content

Instantly share code, notes, and snippets.

@u1and0
Last active July 22, 2018 09:00
Show Gist options
  • Select an option

  • Save u1and0/9b93f9a299bd4a9a4380b672f2da2d39 to your computer and use it in GitHub Desktop.

Select an option

Save u1and0/9b93f9a299bd4a9a4380b672f2da2d39 to your computer and use it in GitHub Desktop.
Jupyter, Ipythonの設定 ~起動、グラフの日本語表示、エイリアス、インライン表示、スタートアップモジュールインポート~ ref: https://qiita.com/u1and0/items/a926a7be5d182932a929
[In] %load_ext autoreload # マジックコマンド%autoreloadをロードする
[In] %autoreload hello
[In] hello.hello()
[Out] f**k!
__modules__ = ('numpy',
'pandas',
'matplotlib.pyplot',
'seaborn')
__standfor__ = {'numpy': 'np',
'pandas': 'pd',
'matplotlib.pyplot': 'plt',
'seaborn': 'sns'}
for __module__ in __modules__:
__execution__ = 'import %s as %s' % (__module__, __standfor__[__module__])
print(__execution__)
exec(__execution__)
__inline__ = 'matplotlib inline'
__gui__ = 'matplotlib auto'
try:
get_ipython().magic(__inline__)
print('%' + __inline__)
except:
get_ipython().magic(__gui__)
print('%' + __gui__)
print("If you'd like to use `plt.show()` command,")
print('you can type `plt.ioff()`/`plt.ion()` to turn interactive mode off/on.')
cmd /k "jupyter qtconsole --style=monokai" -new_console:t:"Jupyter" -new_console:b
cmd /k "%ConEmuDir%\..\init.bat" -new_console:d:%HOME%\python & ipython
UnknownBackend: No event loop integration for 'inline'.
Supported event loops are: qt, qt4, qt5, gtk, gtk2, gtk3, tk, wx, pyglet, glut, osx
If you use `plt.show()` command,
you should use `plt.ioff()` to turn interactive mode off.
[In] %autoreload 2 # すべてのモジュールを常にリロード
def hello():
print('hello')
def hello():
print('f**k!')
[In]import hello
## ~~hello.pyの書き換え~~
[In]import imp
[In]imp.reload(hello)
[In] hello.hello()
[Out] f**k!
c.AliasManager.user_aliases = [
# shell command
('ls', 'ls --show-control-chars -F --color'),
('grep', 'grep --color'),
('grepx', 'grep --color -nriC'),
('find', 'find . -name'),
# git
('g', 'git'),
('gf', 'git flow'),
# add,commit,push
('ga', 'git add'),
('gaa', 'git add .'),
('gan', 'git add -n .'),
('gaundo', 'git reset HEAD'),
('gc', 'git commit'),
('gac', 'git commit -am'),
('gcundo', 'git commit --amend'),
('gp', 'git push'),
('gpo', 'git push origin'),
# status
('gs', 'git status --short --branch'),
('gd', 'git diff --color-words'),
('gls', 'git ls-files'),
('gl', 'git log --oneline --all --graph --decorate'),
# branch
('gb', 'git branch'),
('gch', 'git checkout'),
('gm', 'git merge'),
('gt', 'git tag'),
]
c.InteractiveShellApp.exec_lines = ['%load_ext autoreload', '%autoreload 2']
c.InlineBackend.rc = {'font.family': 'IPAMincho',
'figure.facecolor': (1, 1, 1, 1),
'savefig.dpi': 72,
'figure.subplot.bottom': 0.125,
'figure.edgecolor': (1, 1, 1, 1)}
[In] import hello
[In] hello.hello()
[Out] hello
c.InteractiveShellApp.exec_lines = ['%load_ext autoreload', '%autoreload 2']
font.family : IPAMincho
...
def set(context="notebook", style="darkgrid", palette="deep",
font="IPAMincho", font_scale=1, color_codes=False, rc=None):
...
c.InteractiveShellApp.exec_lines = ['%load_ext autoreload', '%autoreload 2']
jupyter notebook -new_console:t:"Jupyter Notebook" -new_console:b
$ ipython profile create <name>
[In] import hello
[In] hello.hello()
[Out] hello
## ここは'f**k!'と表示されたかった。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment