Viewing Progress

Progress Bar

Passing the verbose=True argument to the Contour.roots method or find_roots function will cause a progress bar to be printed:

from cxroots import Circle

C = Circle(0, 3)
f = lambda z: (z + 1.2) ** 3 * (z - 2.5) ** 2 * (z + 1j)
C.roots(f, verbose=True)
_images/cxroots_progress.gif

Logging

More detailed runtime information is available using Python’s standard logging module, for example:

import logging
from numpy import exp, cos, sin
from cxroots import Circle

C = Circle(0, 3)
f = lambda z: (exp(-z) * sin(z / 2) - 1.2 * cos(z)) * (z + 1.2) * (z - 2.5) ** 2

# use logging.DEBUG to show diagnostic information
logging.basicConfig(level=logging.INFO) 
C.roots(f)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
    from docex_logging import *
  File "/build/reproducible-path/cxroots-3.2.0+ds/docs_src/docex_logging.py", line 3, in <module>
    from cxroots import Circle
ModuleNotFoundError: No module named 'cxroots'

Logging with Progress Bar

To get the logs to neatly stream above the progress bar the logging config needs to be passed the RichHandler like so:

import logging
from rich.logging import RichHandler
from numpy import exp, cos, sin
from cxroots import Circle

C = Circle(0, 3)
f = lambda z: (exp(-z) * sin(z / 2) - 1.2 * cos(z)) * (z + 1.2) * (z - 2.5) ** 2

logging.basicConfig(level=logging.INFO, handlers=[RichHandler()])
C.roots(f, verbose=True)
_images/cxroots_logging_progress.gif