Drop the bins entry from plot_param_updates' docstring - #1155
Conversation
`SkorchDoctor.plot_param_updates` documents a `bins` parameter it does not accept. It is a line plot over time, not a histogram, so there are no bins to configure - the entry was carried over from the histogram methods (`plot_activations`, `plot_gradients` and the two *_over_time plots), which all really do take `bins`. Following the docstring fails: `bins` falls through `**kwargs` into `ax.plot`, which raises `AttributeError: Line2D.set() got an unexpected keyword argument 'bins'`.
There was a problem hiding this comment.
Thanks for fixing the docstring, including "bins" there was indeed a mistake.
One thing I left alone: the
**kwargsentry here (and in the sibling plot methods) describesfigsizeas something you override through**kwargs, even thoughfigsizeis an explicit parameter in each of those signatures.
This was certainly not intentional, more of an oversight. I think it would make sense to mention another argument there instead of "figsize", something like "lw" (line width). If you're up to it, please update the docstrings there as well.
The **kwargs entries offered `figsize` as an example, but `figsize` is an
explicit parameter of every one of these methods, so it never reaches
**kwargs. Replaced it per method with an argument that does, chosen against
what each method already forwards:
plot_activations / plot_gradients -> alpha (ax.hist already gets
histtype, lw, bins, density)
plot_param_updates -> lw (ax.plot gets only label)
plot_activations_over_time /
plot_gradient_over_time -> linestyle (fill_between already gets
alpha, color, lw)
`lw` works for plot_param_updates but not for the histogram methods: passing
it through **kwargs there raises "got multiple values for keyword argument
'lw'", which is the same class of mistake as the `figsize` mention.
|
Done — though
So:
I checked each replacement actually goes through rather than assuming —
|
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for the update. I went through the docstrings again and found that the arguments are still very inconsistently documented. Ideally, we would have documentation exactly for the arguments that are indeed present. So as an example, in plot_gradient_over_time, lw, figsize, and color are not documented. Is that something you'd like to tackle?
Following up on review: the plot methods documented only some of their
parameters. Added the missing entries so each Parameters section matches
its signature exactly.
plot_loss had no Parameters section at all
(ax, figsize, **kwargs) plus a Returns section
plot_activations histtype, lw, density, figsize
plot_gradients histtype, lw, density, figsize
plot_param_updates figsize
plot_activations_over_time lw, figsize, color
plot_gradient_over_time lw, figsize, color
All six now document exactly the arguments present, no more and no fewer.
|
Happy to — done. Every plot method now documents exactly the arguments it takes.
I checked it both directions rather than by eye — comparing each signature against its parsed Parameters section, there are now no missing entries and no documented-but-absent ones across all six. numpydoc also parses each of them with zero warnings, and the parameter counts line up with the signatures (e.g. One small wording note: I described
|
|
Note on the red CI: the failures are the model-convergence assertions ( |
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for bringing all the docstrings in line, LGTM.
SkorchDoctor.plot_param_updatesdocuments abinsparameter it doesn't accept:It's a line plot of relative parameter updates over time, not a histogram, so there are no bins to configure. The entry looks carried over from the methods that genuinely have it —
plot_activations,plot_gradients,plot_activations_over_timeandplot_gradient_over_timeall take a realbinsargument and use it fornp.linspace(...).plot_param_updatesis the only one of the six that documents it without having it.Following the docstring doesn't just get ignored, it fails:
binsfalls through**kwargsintoax.plot(xvec, values, label=key, **kwargs), and matplotlib rejects it.Docs only — just the four lines removed, no code touched.
skorch/tests/test_doctor.pypasses (42 tests).One thing I left alone: the
**kwargsentry here (and in the sibling plot methods) describesfigsizeas something you override through**kwargs, even thoughfigsizeis an explicit parameter in each of those signatures. That's consistent across the methods, so it reads like a deliberate house phrasing rather than a mistake, and I didn't want to churn several docstrings on my own reading of it. Happy to tidy that up separately if you'd like it changed.I also skipped a
CHANGES.mdentry since this doesn't change behaviour — let me know if you'd prefer one under Fixed.