๋ ์ด์ ์ฌ์ฉ๋์ง ์๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ NumPy 1.14๋ก ์์
์ ์ํํ ๋ ๊ฒฝ๊ณ ๊ฐ ์ปจํ
์คํธ์ ๋ฐ๋ผ IPython ๋๋ IPython ์ปค๋๋ก ๋ค์ ์ถ์ ๋๋ ๊ฒ์ฒ๋ผ ๋ณด์
๋๋ค. ์ด๋ ์ฝ๊ฐ ์คํด์ ์์ง๊ฐ ์์ต๋๋ค. Jupyter Notebook์์ This is separate from the ipykernel package so we can avoid doing imports until
๋ผ๋ ์ฝ๊ฐ์ ์ถ๊ฐ ํ
์คํธ๋ฅผ ์ถ๊ฐํ๊ณ ๊ทธ๋๋ก ์ถ์ ํฉ๋๋ค(๋ฐ๋ผ์ ์ฌ๊ธฐ์์ ๋จผ์ ์ฌ๋ฆฝ๋๋ค). ์ด๊ฒ์ด IPython, IPython ์ปค๋ ๋๋ NumPy์ ๋ฌธ์ ์ธ์ง ํ์คํ์ง ์์ต๋๋ค. ์ฌ๊ธฐ MRE๊ฐ ์์ต๋๋ค.
์์:
In [1]: import numpy as np
In [2]: a = np.arange(24).reshape(1, 2, 3, 4)
In [3]: np.expand_dims(a.min(), a.ndim)
/zopt/conda2/envs/test/bin/ipython:1: DeprecationWarning: Both axis > a.ndim and axis < -a.ndim - 1 are deprecated and will raise an AxisError in the future.
#!/zopt/conda2/envs/test/bin/python
Out[3]: array([0])
ํ๊ฒฝ:
name: test
channels:
- conda-forge
- defaults
dependencies:
- appnope=0.1.0=py36_0
- backcall=0.1.0=py_0
- blas=1.1=openblas
- ca-certificates=2018.1.18=0
- certifi=2018.1.18=py36_0
- decorator=4.2.1=py36_0
- ipython=6.3.1=py36_0
- ipython_genutils=0.2.0=py36_0
- jedi=0.11.1=py36_0
- libgfortran=3.0.0=0
- ncurses=5.9=10
- numpy=1.14.2=py36_blas_openblas_200
- openblas=0.2.20=7
- openssl=1.0.2n=0
- parso=0.1.1=py_0
- pexpect=4.4.0=py36_0
- pickleshare=0.7.4=py36_0
- pip=9.0.3=py36_0
- prompt_toolkit=1.0.15=py36_0
- ptyprocess=0.5.2=py36_0
- pygments=2.2.0=py36_0
- python=3.6.5=1
- readline=7.0=0
- setuptools=39.0.1=py36_0
- simplegeneric=0.8.1=py36_0
- six=1.11.0=py36_1
- sqlite=3.20.1=2
- tk=8.6.7=0
- traitlets=4.3.2=py36_0
- wcwidth=0.1.7=py36_0
- wheel=0.31.0=py36_0
- xz=5.2.3=0
- zlib=1.2.11=0
์, ์ด๊ฒ์ __main__
๊ฐ ๋ ๊ฐ์ง ๋ค๋ฅธ ๊ฒ์ ๋ํ๋ด๋๋ก ํ ๊ฒฐ๊ณผ์
๋๋ค. __main__
๋ชจ๋์ ์ผ๋ถ๋ก ์คํ๋๋ ๋ํ์์ผ๋ก ์
๋ ฅํ ์ฝ๋์ 1ํ์ ๋ํ ๊ฒฝ๊ณ ๋ฅผ ๋ฐํํ๋ ค๊ณ ํฉ๋๋ค. ๊ทธ๋ฌ๋ ๋ผ์ธ์ ๋ค๋ฅธ __main__
๋ชจ๋์์ ๋์ต๋๋ค. Python์ด IPython์ ์์ํ๊ฑฐ๋ ์ปค๋์ ์์ํ๊ธฐ ์ํด ์คํํ ํ์ผ์
๋๋ค. ๋ฐ๋ผ์ ๋ณด์ด๋ ํ
์คํธ๋ ํด๋น ํ์ผ์ ์ฒซ ๋ฒ์งธ ์ค์
๋๋ค( This is separate...
ํ
์คํธ๋ ๋
์คํธ๋ง์
๋๋ค).
์ฝ๊ฐ ์ง์ ๋ถํ๊ณ ํผ๋์ค๋ฝ์ง๋ง ๊ณ ์น ๊ฐ์น๊ฐ ์์ ๋งํผ ํฐ ๋ฌธ์ ๋ ๊ฒฐ์ฝ ์๋๋๋ค.
๊ถ๊ธํด์ ์๋ฆฌ๋ฅผ ํ๋ฌ ๊ฐ์ต๋๋ค. __main__
๊ธฐ์ธํ ๋ชจ๋ ๊ฒฝ๊ณ ์์ ์ฝ๋๋ฅผ ์์ฃผ ์ฝ๊ฒ ์ ์ธํ ์ ์์ง๋ง ์ด๋ ์ฝ๊ฐ ๋ถ๋ง์กฑ์ค๋ฝ์ต๋๋ค. ๋ด๊ฐ ์ ์ ์๋ ํ ์ฌ๋ฐ๋ฅธ ์ฝ๋๋ฅผ ํ์ํ๋ ๊ฒ์ IPython์ ๋ถ๊ฐ๋ฅํฉ๋๋ค. ๊ฒฝ๊ณ ๋ชจ๋์ด ๊ณ ์ ํ ๊ด์ฉ๊ตฌ๋ก ์ฝ๋๋ฅผ ์กฐํํ๊ธฐ ๋๋ฌธ์
๋๋ค.
์ญ์ถ์ ๋ฐ pdb๋ ๋ค์์ ์ํํ์ฌ ํ์ผ์ ์ฐพ์ต๋๋ค.
frame.f_code.co_filename
Warnings๋ ๋ค์๊ณผ ๊ฐ์ ์์ ์ ์ํํ์ฌ ํ์ผ์ ์ฐพ์ต๋๋ค.
frame.f_globals.get('__file__', sys.argv[0])
๊ฐ ์ ๋ ฅ์ ์ฝ๋์ ๋ํ ๊ณ ์ ํ ๊ฐ์ง ํ์ผ ์ด๋ฆ์ ์ง์ ํ์ฌ ์ญ์ถ์ ์ ์ฐพ์ ์ ์์ต๋๋ค. ํ์ง๋ง ๋ชจ๋ ์ ์ญ ๋ค์์คํ์ด์ค๋ฅผ ๊ณต์ ํด์ผ ํ๋ฏ๋ก ํ์ฌ๋ก์๋ ๊ฒฝ๊ณ ๋ก ๊ตฌ๋ถํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค. ๋๋ ๊ณ ๋ Python ๋ฌธ์ ์ ๋ํด ์ด๊ฒ์ ๋ํด ๋ฐฉ๊ธ ์ธ๊ธ
Python์ ์ ์ถํ PR์ด ๋ณํฉ๋์์ผ๋ฏ๋ก Python 3.8์์ ์์ ํด์ผ ํฉ๋๋ค.
@takluyver ๊ฐ์ฌํฉ๋๋ค!
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
Python์ ์ ์ถํ PR์ด ๋ณํฉ๋์์ผ๋ฏ๋ก Python 3.8์์ ์์ ํด์ผ ํฉ๋๋ค.
https://github.com/python/cpython/pull/6622