You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am in the process to write a library that uses the matplotlib library for its graphics needs. As such, most of "our" graphics functions are wrappers around existing matplotlib functions such as tripcolor, tricontour… A typical function of ours would be:
In this case the kwargs dictionnary may contain keywords aimed at the prepare_args process and keywords aimed at controlling the plotting. At the moment, prepare_args removes keywords from the dictionnary when used so that in principle, when kwargs arrive at plt.fun_name, it should only contain keywords known to plt.fun_name
However, if the user makes a mistake while setting the keyword for OUR part, it is not properly handled by prepare_args and it does remain inside kwargs and then is passed to plt.fun_name which then raises an AttributeError('... got an unexpected keyword argument ...').
I would like to be able to try and recover if that happens.
The name and obj attributes can be set using keyword-only arguments to the constructor. When set they represent the name of the attribute that was attempted to be accessed and the object that was accessed for said attribute, respectively.
Changed in version 3.10: Added the name and obj attributes
I looked at the matplotlib codebase but I am not an expert programmer so I may be wrong but I think what I would like was that Artist._update_props set the name attribute to k when raising the AttributeError.
Since I am using Python 3.11 this would allow me to try and remove spurious keywords.
The text was updated successfully, but these errors were encountered:
This will break for python 3.9 but, according to the NEP29 schedule, we should be dropping support for that in April anyway. So if we target this for Matplotlib 3.10 there will be no problem.
Problem
I am in the process to write a library that uses the matplotlib library for its graphics needs. As such, most of "our" graphics functions are wrappers around existing matplotlib functions such as tripcolor, tricontour… A typical function of ours would be:
In this case the
kwargs
dictionnary may contain keywords aimed at theprepare_args
process and keywords aimed at controlling the plotting. At the moment,prepare_args
removes keywords from the dictionnary when used so that in principle, whenkwargs
arrive atplt.fun_name
, it should only contain keywords known toplt.fun_name
However, if the user makes a mistake while setting the keyword for OUR part, it is not properly handled by
prepare_args
and it does remain insidekwargs
and then is passed toplt.fun_name
which then raises anAttributeError('... got an unexpected keyword argument ...')
.I would like to be able to try and recover if that happens.
Proposed solution
From the Built-in Exceptions documentation page
I looked at the matplotlib codebase but I am not an expert programmer so I may be wrong but I think what I would like was that
Artist._update_props
set thename
attribute tok
when raising theAttributeError
.Since I am using Python 3.11 this would allow me to try and remove spurious keywords.
The text was updated successfully, but these errors were encountered: