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

[Docs] Fix the rendering issues in documentation docstrings #282

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Preparing Pull Requests
whenever you commit.

Now you have an environment called ``bitinfo`` that you can work in.
Youll need to make sure to activate that environment next time you want
You'll need to make sure to activate that environment next time you want
to use it after closing the terminal or your system.

You can now edit your local working copy and run/add tests as necessary.
Expand All @@ -117,9 +117,7 @@ Preparing Pull Requests

``pre-commit`` also runs::

* `mypy <http://mypy-lang.org/>`_ for static type checking on
`type hints <https://docs.python.org/3/library/typing.html>`_.
* `isort <https://pycqa.github.io/isort/>`_ sorting imports
* `ruff <https://docs.astral.sh/ruff/>`_ code formatter.
* `black <https://black.readthedocs.io/en/stable/>`_ code formatting
* `flake8 <https://flake8.pycqa.org/en/latest/>`_ code linting
..
Expand Down
2 changes: 2 additions & 0 deletions xbitinfo/graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def add_bitinfo_labels(
Example
-------
Plotting a single-dimension coordinate dataset:

>>> ds = xr.tutorial.load_dataset("air_temperature")
>>> info_per_bit = xb.get_bitinformation(ds, dim="lon")
>>> inflevels = [1.0, 0.9999, 0.99, 0.975, 0.95]
Expand All @@ -72,6 +73,7 @@ def add_bitinfo_labels(
... ) # doctest: +ELLIPSIS

Plotting a multi-dimensional coordinate dataset

>>> v = "Tair"
>>> ds = xr.tutorial.load_dataset("rasm")
>>> dim = "y"
Expand Down
10 changes: 7 additions & 3 deletions xbitinfo/xbitinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,22 +678,26 @@ def get_prefect_flow(paths=[]):
Example
-------
Imagine n files of identical structure, i.e. 1-year per file climate model output:

>>> ds = xr.tutorial.load_dataset("rasm")
>>> year, datasets = zip(*ds.groupby("time.year"))
>>> paths = [f"{y}.nc" for y in year]
>>> xr.save_mfdataset(datasets, paths)

Create prefect.Flow and run sequentially

>>> flow = xb.get_prefect_flow(paths=paths)
>>> import prefect
>>> logger = prefect.context.get("logger")
>>> logger.setLevel("ERROR")
>>> st = flow.run()

Inspect flow state

>>> # flow.visualize(st) # requires graphviz

Run in parallel with dask:

>>> import os # https://docs.xarray.dev/en/stable/user-guide/dask.html
>>> os.environ["HDF5_USE_FILE_LOCKING"] = "FALSE"
>>> from prefect.executors import DaskExecutor, LocalDaskExecutor
Expand All @@ -707,14 +711,14 @@ def get_prefect_flow(paths=[]):
>>> # flow.run(executor=executor, parameters=dict(overwrite=True))

Modify parameters of a flow:

>>> flow.run(parameters=dict(inflevel=0.9999, overwrite=True))
<Success: "All reference tasks succeeded.">

See also
--------
- https://examples.dask.org/applications/prefect-etl.html
- https://docs.prefect.io/core/getting_started/basic-core-flow.html

`ETL Pipelines with Prefect <https://examples.dask.org/applications/prefect-etl.html/>`__ and
`Run a flow <https://docs.prefect.io/core/getting_started/basic-core-flow.html>`__
"""

from prefect import Flow, Parameter, task, unmapped
Expand Down