'Pandas plotting routine fails with NoneType is not callable, but only when run inside pdb

The following code If I run the following code in pdb (i.e. with python -m pdb)

if __name__=='__main__':
    import pandas as pd

    df=pd.DataFrame([[0,1,2],[63,146, 135]])
    df.plot.area()

it fails with a TypeError inside a numpy routine that's called by matplotlib:

> python -m pdb test_dtype.py 
> /home/jhaiduce/financial/forecasting/test_dtype.py(1)<module>()
-> if __name__=='__main__':
(Pdb) r
QSocketNotifier: Can only be used with threads started with QThread
--Return--
> /home/jhaiduce/financial/forecasting/test_dtype.py(6)<module>()->None
-> df.plot.area()
(Pdb) c
Traceback (most recent call last):
  File "/usr/lib64/python3.10/site-packages/numpy/core/getlimits.py", line 384, in __new__
    dtype = numeric.dtype(dtype)
TypeError: 'NoneType' object is not callable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.10/pdb.py", line 1726, in main
    pdb._runscript(mainpyfile)
  File "/usr/lib64/python3.10/pdb.py", line 1586, in _runscript
    self.run(statement)
  File "/usr/lib64/python3.10/bdb.py", line 597, in run
    exec(cmd, globals, locals)
  File "<string>", line 1, in <module>
  File "/home/jhaiduce/financial/forecasting/test_dtype.py", line 6, in <module>
    df.plot.area()
  File "/usr/lib64/python3.10/site-packages/pandas/plotting/_core.py", line 1496, in area
    return self(kind="area", x=x, y=y, **kwargs)
  File "/usr/lib64/python3.10/site-packages/pandas/plotting/_core.py", line 972, in __call__
    return plot_backend.plot(data, kind=kind, **kwargs)
  File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/__init__.py", line 71, in plot
    plot_obj.generate()
  File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 294, in generate
    self._post_plot_logic_common(ax, self.data)
  File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 473, in _post_plot_logic_common
    self._apply_axis_properties(ax.xaxis, rot=self.rot, fontsize=self.fontsize)
  File "/usr/lib64/python3.10/site-packages/pandas/plotting/_matplotlib/core.py", line 561, in _apply_axis_properties
    labels = axis.get_majorticklabels() + axis.get_minorticklabels()
  File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1201, in get_majorticklabels
    ticks = self.get_major_ticks()
  File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1371, in get_major_ticks
    numticks = len(self.get_majorticklocs())
  File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1277, in get_majorticklocs
    return self.major.locator()
  File "/usr/lib64/python3.10/site-packages/matplotlib/ticker.py", line 2113, in __call__
    vmin, vmax = self.axis.get_view_interval()
  File "/usr/lib64/python3.10/site-packages/matplotlib/axis.py", line 1987, in getter
    return getattr(getattr(self.axes, lim_name), attr_name)
  File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 781, in viewLim
    self._unstale_viewLim()
  File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 776, in _unstale_viewLim
    self.autoscale_view(**{f"scale{name}": scale
  File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 2932, in autoscale_view
    handle_single_axis(
  File "/usr/lib64/python3.10/site-packages/matplotlib/axes/_base.py", line 2895, in handle_single_axis
    x0, x1 = locator.nonsingular(x0, x1)
  File "/usr/lib64/python3.10/site-packages/matplotlib/ticker.py", line 1654, in nonsingular
    return mtransforms.nonsingular(v0, v1, expander=.05)
  File "/usr/lib64/python3.10/site-packages/matplotlib/transforms.py", line 2880, in nonsingular
    if maxabsvalue < (1e6 / tiny) * np.finfo(float).tiny:
  File "/usr/lib64/python3.10/site-packages/numpy/core/getlimits.py", line 387, in __new__
    dtype = numeric.dtype(type(dtype))
TypeError: 'NoneType' object is not callable
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> /usr/lib64/python3.10/site-packages/numpy/core/getlimits.py(387)__new__()
-> dtype = numeric.dtype(type(dtype))
(Pdb) 

The error occurs only when run in the debugger; the program runs as normal when run outside the debugger.

Any idea what could be the cause of this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source