Add a common docstring by reusing the DataArray one. TODO: Reduce code duplication. * The goal is to reduce code duplication by moving all Dataset specific plots to the DataArray side and use this thin wrapper to handle the conversion between Dataset and DataArray. * I
(dataarray_plotfunc: Callable)
| 656 | |
| 657 | |
| 658 | def _update_doc_to_dataset(dataarray_plotfunc: Callable) -> Callable[[F], F]: |
| 659 | """ |
| 660 | Add a common docstring by reusing the DataArray one. |
| 661 | |
| 662 | TODO: Reduce code duplication. |
| 663 | |
| 664 | * The goal is to reduce code duplication by moving all Dataset |
| 665 | specific plots to the DataArray side and use this thin wrapper to |
| 666 | handle the conversion between Dataset and DataArray. |
| 667 | * Improve docstring handling, maybe reword the DataArray versions to |
| 668 | explain Datasets better. |
| 669 | |
| 670 | Parameters |
| 671 | ---------- |
| 672 | dataarray_plotfunc : Callable |
| 673 | Function that returns a finished plot primitive. |
| 674 | """ |
| 675 | |
| 676 | # Build on the original docstring |
| 677 | da_doc = dataarray_plotfunc.__doc__ |
| 678 | if da_doc is None: |
| 679 | raise NotImplementedError("DataArray plot method requires a docstring") |
| 680 | |
| 681 | da_str = """ |
| 682 | Parameters |
| 683 | ---------- |
| 684 | darray : DataArray |
| 685 | """ |
| 686 | ds_str = """ |
| 687 | |
| 688 | The `y` DataArray will be used as base, any other variables are added as coords. |
| 689 | |
| 690 | Parameters |
| 691 | ---------- |
| 692 | ds : Dataset |
| 693 | """ |
| 694 | # TODO: improve this? |
| 695 | if da_str in da_doc: |
| 696 | ds_doc = da_doc.replace(da_str, ds_str).replace("darray", "ds") |
| 697 | else: |
| 698 | ds_doc = da_doc |
| 699 | |
| 700 | @functools.wraps(dataarray_plotfunc) |
| 701 | def wrapper(dataset_plotfunc: F) -> F: |
| 702 | dataset_plotfunc.__doc__ = ds_doc |
| 703 | return dataset_plotfunc |
| 704 | |
| 705 | return wrapper # type: ignore[return-value] |
| 706 | |
| 707 | |
| 708 | def _normalize_args( |
nothing calls this directly
no test coverage detected
searching dependent graphs…