Skip to content

Remove self from classes in How to add new backends docs - #5532

Merged
max-sixty merged 1 commit into
pydata:mainfrom
Illviljan:Illviljan-backend_docs
Jun 25, 2021
Merged

Remove self from classes in How to add new backends docs#5532
max-sixty merged 1 commit into
pydata:mainfrom
Illviljan:Illviljan-backend_docs

Conversation

@Illviljan

@IllviljanIllviljan commented Jun 25, 2021

Copy link
Copy Markdown
Contributor

Copy pasting the examples in http://xarray.pydata.org/en/stable/internals/how-to-add-new-backend.html resulted in crashes. Make the docs copy/paste friendly by removing the self arguments.

Example:

expected=xr.Dataset(
dict(a=2*np.arange(5)), coords=dict(x=("x", np.arange(5), dict(units="s")))
)
classCustomBackend(xr.backends.BackendEntrypoint):
defopen_dataset(
self,
filename_or_obj,
drop_variables=None,
**kwargs,
):
returnexpected.copy(deep=True)
xr.open_dataset("fake_filename", engine=CustomBackend)
TypeError: open_dataset() missing1requiredpositionalargument: 'filename_or_obj'

This works if self is removed:

expected=xr.Dataset(
dict(a=2*np.arange(5)), coords=dict(x=("x", np.arange(5), dict(units="s")))
)
classCustomBackend(xr.backends.BackendEntrypoint):
defopen_dataset(
filename_or_obj,
drop_variables=None,
**kwargs,
):
returnexpected.copy(deep=True)
xr.open_dataset("fake_filename", engine=CustomBackend)
<xarray.Dataset>Dimensions: (a: 5, x: 5)
Coordinates:
*a (a) int3202468*x (x) int3201234Datavariables:
*empty*
  • Passes pre-commit run --all-files

@IllviljanIllviljan changed the title Remove self from classes in how to add new backendsRemove self from classes in How to add new backends docsJun 25, 2021
@max-sixty

Copy link
Copy Markdown
Collaborator

Thank you again @Illviljan !

@max-sixty
max-sixty merged commit 697e9a9 into pydata:mainJun 25, 2021
@github-actions

Copy link
Copy Markdown
Contributor

Unit Test Results

0 files ±0 0 suites ±0 0s ⏱️ ±0s
0 tests ±0 0 ✔️ ±0 0 💤 ±0 0 ❌ ±0 

Results for commit 697e9a9. ± Comparison against base commit 697e9a9.

@Illviljan
Illviljan deleted the Illviljan-backend_docs branch July 2, 2021 16:07
keewis added a commit that referenced this pull request Sep 8, 2021
keewis added a commit that referenced this pull request Sep 8, 2021
Sign up for freeto 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

@Illviljan@max-sixty