Python测试由于TCL误差而在Matplotlib子图上随机失败
由于TCL错误,我在plt.subplots上失败了测试。这是测试,并在上升错误的行中:
def test_plot_epoch_segmentation():
"""Test segmentation plots for epochs."""
n_clusters = 4
labels = np.random.choice(
[-1, 0, 1, 2, 3], (len(epochs), epochs.times.size)
)
plot_epoch_segmentation(labels, epochs, n_clusters)
plt.close("all")
# provide ax
f, ax = plt.subplots(1, 1)
plot_epoch_segmentation(labels, epochs, n_clusters, axes=ax)
plt.close("all")
# provide cbar_ax
>> f, cbar_ax = plt.subplots(1, 1)
请注意,上面的4行...相似的plt.subplots
被调用,并且不会升高。毫无疑问,这是提出的错误:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\matplotlib\pyplot.py:1455: in subplots
fig = figure(**fig_kw)
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\matplotlib\pyplot.py:808: in figure
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\matplotlib\backends\_backend_tk.py:949: in new_figure_manager_given_figure
window = tk.Tk(className="matplotlib")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tkinter.Tk object .>, screenName = None, baseName = 'pytest'
className = 'matplotlib', useTk = True, sync = False, use = None
def __init__(self, screenName=None, baseName=None, className='Tk',
useTk=True, sync=False, use=None):
"""Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
be created. BASENAME will be used for the identification of the profile file (see
readprofile).
It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
is the name of the widget class."""
self.master = None
self.children = {}
self._tkloaded = False
# to avoid recursions in the getattr code in case of failure, we
# ensure that self.tk is always _something_.
self.tk = None
if baseName is None:
import os
baseName = os.path.basename(sys.argv[0])
baseName, ext = os.path.splitext(baseName)
if ext not in ('.py', '.pyc'):
baseName = baseName + ext
interactive = False
> self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
E _tkinter.TclError: invalid command name "tcl_findLibrary"
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\tkinter\__init__.py:2270: TclError
如果有人有想法。.任何帮助将不胜感激!
I have a test failing on a plt.subplots
call because of a Tcl error.. and I can't figure out why or how to fix it. Here is the test, with the line on which the error is raised:
def test_plot_epoch_segmentation():
"""Test segmentation plots for epochs."""
n_clusters = 4
labels = np.random.choice(
[-1, 0, 1, 2, 3], (len(epochs), epochs.times.size)
)
plot_epoch_segmentation(labels, epochs, n_clusters)
plt.close("all")
# provide ax
f, ax = plt.subplots(1, 1)
plot_epoch_segmentation(labels, epochs, n_clusters, axes=ax)
plt.close("all")
# provide cbar_ax
>> f, cbar_ax = plt.subplots(1, 1)
Note that 4 lines above... a similar plt.subplots
is called and does not raise. Without further due, here is the error raised:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\matplotlib\pyplot.py:1455: in subplots
fig = figure(**fig_kw)
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\matplotlib\pyplot.py:808: in figure
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\matplotlib\backends\_backend_tk.py:949: in new_figure_manager_given_figure
window = tk.Tk(className="matplotlib")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tkinter.Tk object .>, screenName = None, baseName = 'pytest'
className = 'matplotlib', useTk = True, sync = False, use = None
def __init__(self, screenName=None, baseName=None, className='Tk',
useTk=True, sync=False, use=None):
"""Return a new Toplevel widget on screen SCREENNAME. A new Tcl interpreter will
be created. BASENAME will be used for the identification of the profile file (see
readprofile).
It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
is the name of the widget class."""
self.master = None
self.children = {}
self._tkloaded = False
# to avoid recursions in the getattr code in case of failure, we
# ensure that self.tk is always _something_.
self.tk = None
if baseName is None:
import os
baseName = os.path.basename(sys.argv[0])
baseName, ext = os.path.splitext(baseName)
if ext not in ('.py', '.pyc'):
baseName = baseName + ext
interactive = False
> self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
E _tkinter.TclError: invalid command name "tcl_findLibrary"
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\tkinter\__init__.py:2270: TclError
If anyone has an idea.. any help would be appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论