Skip to content

Fix docstring parameters that are not in the signature - #2556

Open
VenishPaneliya wants to merge 1 commit into
MaartenGr:masterfrom
VenishPaneliya:docstring-params-not-in-signature
Open

VenishPaneliya wants to merge 1 commit into
MaartenGr:masterfrom
VenishPaneliya:docstring-params-not-in-signature

Conversation

@VenishPaneliya

Copy link
Copy Markdown

griffe reports seven docstring parameters in bertopic that do not exist in the signature they document. They render in the API reference, so the docs advertise arguments that cannot be passed.

The one with a real consequence is VisualRepresentation: the class docstring documents image_square, but the constructor parameter is image_squares, so following the documentation gives

TypeError: __init__() got an unexpected keyword argument 'image_square'. Did you mean 'image_squares'?

That one is a rename; the other six are entries that no longer match anything and are removed:

location documented reality
VisualRepresentation image_square parameter is image_squares
visualize_documents, visualize_document_datamap, visualize_approximate_distribution, visualize_hierarchy topic_model first parameter of the function in bertopic.plotting, not of the method
BERTopic._c_tf_idf m explained in the summary line, not a parameter
KeyBERTInspired._extract_top_words labels a local computed from topics

The eight other visualize_* methods already omit topic_model, and TopicMapper.add_mappings documents it because it really does take it, so this is drift rather than house style. image_square has been wrong since #1232.

Docstrings only, no behaviour change. ruff check and ruff format --check pass. Loading the package with griffe goes from seven "does not appear in the function signature" warnings to zero. Filed directly rather than via an issue first, since CONTRIBUTING lists docstrings as an exception to that flow.

VisualRepresentation documents image_square, but the constructor takes
image_squares, so following the docs raises TypeError. Four visualize_*
methods still document topic_model, which is a parameter of the
underlying function in bertopic.plotting, not of the method. _c_tf_idf
documents m and KeyBERTInspired._extract_top_words documents labels;
both are local names, not parameters.
@VenishPaneliya

Copy link
Copy Markdown
Author

Heads-up on the red CI here: the three failures (test_barchart, test_barchart_outlier, test_topic_reduction) are not from this branch. This PR only edits docstring text — no code, no signatures — so nothing in it can change an annotation count or an array index.

They look like dependency drift on master rather than a regression: the last green master run was back in August, and the failures are assert 7 == 8 on fig["layout"]["annotations"] plus IndexError: index 65 is out of bounds for axis 1 with size 7 in _bertopic.py:4793, both consistent with a newer plotly/numpy than the suite was last pinned against. Happy to leave it, just didn't want the red X to make this look broken.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant