Skip to content

Add a context manager as an alternative to monkey patching#91

Open
krokosik wants to merge 6 commits into
arviz-devs:mainfrom
krokosik:feat-default-dims-context-manager
Open

Add a context manager as an alternative to monkey patching#91
krokosik wants to merge 6 commits into
arviz-devs:mainfrom
krokosik:feat-default-dims-context-manager

Conversation

@krokosik

Copy link
Copy Markdown

Closes #29

@read-the-docs-community

read-the-docs-community Bot commented Apr 15, 2026

Copy link
Copy Markdown



@contextmanager
def default_linalg_dims(func_or_dims):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the body can be kept mostly as is, the only change is I would define it inside the linalg.py file so it is also imported from xarray_einstats.linalg instead of being available at the top level. We might then want to remove the linalg from the name but I am also fine keeping it.

Comment on lines +211 to +213
Yields
------
None

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numpydoc doesn't say anything on documenting context managers but I would remove this section and instead add an examples section or a seealso pointing to the docs on using it. In general I would also update all the docs to remove any reference to monkeypatching and rely on the context manager only (I am more than happy to do this myself if you prefer).

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.

Change the monkeypatch thing to using with contexts?

2 participants