This repo contains some simple Python code to show the integation between PyCharm and Scientific Python tools:
- NumPy & matplotlib, see
np_example.py
:- set breakpoint on line 5
- run in debug mode (green beetle)
- step over definition of
X
- right click
X
in the Variables window at the bottom - Choose
View as array
to open a Data View window - Note how the figure window causes the run to halt; to avoid that, add the argument
block=False
toplt.show
(but then the figure window cannot be viewed).
- Cython - support for Cython in PyCharm is limited to editing code (rather than compiling and running it) and is only available in PyCharm Professional.
primes.pyx
defines a new Cython function that returnsn
first primessetup.py
contains neccessary definitions to build the Cython extension: use Tools->Run setup.py task..., choosebuild_ext
and add the parameter--inplace
(otherwise the Cython extension will only be available when installing the package).- Once the extension (
pyx
file) is compileddll
/so
file), you can test it withtest_primes.py
: Right click the project name and choose Run NoseTests in .... timeit_primes.py
demontrates how to time both Python function (primes
) and Cython functions (cprimes
, imported from theprimes
module).
- Jupyter notebook
- PyCharm supports viewing of Jupyter notebooks.
- Start a notebook server by typing in a terminal (can be a PyCharm terminal):
jupyter notebook
- Note that when the notebook server starts it will display a message, look for the
...token=
in the message and copy the token (the text aftertoken
). - Open
notebook.ipynb
- If required, paste that token you copied from the terminal.
- You can run cells with the play button, etc.
- numpy
- matplotlib
- cython
- nose
- ipykernel
- jupyter notebook