Add a NumPy PDB example
This commit is contained in:
parent
5500e1d3b3
commit
b9f44b3be1
1
.gitignore
vendored
1
.gitignore
vendored
@ -19,6 +19,7 @@ early-init.el
|
||||
example.py
|
||||
init.el
|
||||
latexmkrc
|
||||
nuggy.py
|
||||
org-store-link
|
||||
property-syntax-demonstration.org
|
||||
pyproject.toml
|
||||
|
26
README.org
26
README.org
@ -6147,12 +6147,15 @@ configures =code-cells=.
|
||||
:CUSTOM_ID: sec:debug-python
|
||||
:END:
|
||||
|
||||
Listing [[lst:pdb-example]] shows how to start using PDB. Links of interest are:
|
||||
Listing [[lst:pdb-example]] and [[lst:pdb-numpy]] show how to start using PDB.
|
||||
Links of interest are:
|
||||
- [[https://realpython.com/python-debugging-pdb/][Python Debugging with PDB]]
|
||||
- [[https://docs.python.org/3/library/pdb.html][The Python Debugger]]
|
||||
- [[yt:vfPtGsSJldg][Introduction to PDB (Python-2.7 YouTube video)]]
|
||||
- [[https://stackoverflow.com/questions/7668979/how-do-you-watch-a-variable-in-pdb][How do you watch a variable in PDB? (Python-2.7)]]
|
||||
- [[https://stackoverflow.com/questions/51349074/in-python-3-7-does-the-opcode-event-from-sys-settrace-give-any-information-ab][How to use the opcode event (Python-3.7, GAV: why does it fail)?]]
|
||||
- [[https://pypi.org/project/pdbpp/][PDB++]] looks incompatible with Python>3.10: see [[https://github.com/pdbpp/pdbpp/issues/516][Python-3.11 breaks PDBPP]].
|
||||
- [[https://python-scientific-lecture-notes.developpez.com/tutoriel/notes-cours/python-debugging-code/#L3-1][Debugging Python with IPDB under IPython or with PDB in a terminal]].
|
||||
|
||||
#+caption[PDB example: =python -m pdb .emacs.d/buggy.py=]:
|
||||
#+caption: PDB example: =python -m pdb .emacs.d/buggy.py=.
|
||||
@ -6166,6 +6169,27 @@ if __name__ == "__main__":
|
||||
unsafe(1.0, 0.0)
|
||||
#+end_src
|
||||
|
||||
#+caption[PDB NumPy example: =python -m pdb .emacs.d/nuggy.py=]:
|
||||
#+caption: PDB NumPy example: =python -m pdb .emacs.d/nuggy.py=.
|
||||
#+name: lst:pdb-numpy
|
||||
#+begin_src python -i -n :results silent
|
||||
def buggy():
|
||||
from numpy import array, matrix
|
||||
from numpy.linalg import inv
|
||||
|
||||
a = matrix(array([[1.0, 1.0], [1.0, 1.0]]))
|
||||
breakpoint()
|
||||
# Use "display", "p", or "pp" to inspect "a".
|
||||
# A series of "s" does not raise the exception here, contrary to "c".
|
||||
b = inv(a)
|
||||
breakpoint()
|
||||
return b
|
||||
|
||||
if __name__ == "__main__":
|
||||
b = buggy()
|
||||
# The series of "s" says only here "Uncaught exception".
|
||||
#+end_src
|
||||
|
||||
* [[https://github.com/emacs-tw/awesome-emacs#library][Libraries]]
|
||||
:PROPERTIES:
|
||||
:CUSTOM_ID: sec:libraries
|
||||
|
Loading…
Reference in New Issue
Block a user