Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorator helper #4

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Decorator helper #4

wants to merge 7 commits into from

Conversation

flying-sheep
Copy link
Member

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

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.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@flying-sheep flying-sheep changed the title Helper prototypes Decorator helper Feb 27, 2024
@grst
Copy link
Collaborator

grst commented Mar 3, 2024

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
Copy link
Member Author

flying-sheep commented Mar 4, 2024

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 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.

2 participants