Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.

Decorator helper#4

Draft
flying-sheep wants to merge 7 commits into
mainfrom
helpers
Draft

Decorator helper#4
flying-sheep wants to merge 7 commits into
mainfrom
helpers

Conversation

@flying-sheep

@flying-sheep flying-sheep commented Feb 26, 2024

Copy link
Copy Markdown
Member

The “only” problem is that this isn’t actually supported: python/mypy#14832, https://discuss.python.org/t/type-hints-for-kwarg-overrides/47196

If it was, it would have the advantage that we wouldn’t have to manually write overloads for each individual function.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@flying-sheep flying-sheep requested a review from grst February 26, 2024 14:03
@flying-sheep flying-sheep changed the title Helper prototypes Decorator helper Feb 27, 2024
@grst

grst commented Mar 3, 2024

Copy link
Copy Markdown
Collaborator

Looks neat! Would it still work to plot into a single panel of an existing figure?

e.g.

fig, (ax1, ax2) = plt.subplots(2,1)
plot_umap(adata, ax=ax2)

@flying-sheep

flying-sheep commented Mar 4, 2024

Copy link
Copy Markdown
Member Author

The API is unchanged from main. You decorate a function taking fig and gs, and it makes it into a function having ax instead of these two.

As said, the only problem is that Python’s typing doesn‘t actually support modifying kwargs, so as neat as this would be, without a PEP to change this, we’ll have to go the more complicated route.

Or have the function have ax as first argument, which seems cumbersome.

See https://discuss.python.org/t/type-hints-for-kwarg-overrides/47196/7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants